street = $this->normalizeNullableString($this->street); $this->postCode = $this->normalizeNullableString($this->postCode); $this->city = $this->normalizeNullableString($this->city); $this->district = $this->normalizeNullableString($this->district); $this->country = $this->normalizeNullableString($this->country); } /** * Converts the address to API payload format. * * Transforms the address object into an array structure suitable * for API communication with the BusProNet system. * * @return array The payload array for API transmission */ public function toPayload(): array { return [ 'strasse' => $this->street, 'plz' => $this->postCode, 'ort' => $this->city, 'ortsteil' => $this->district, 'land' => $this->country, ]; } private function normalizeNullableString(?string $value): ?string { if (null === $value) { return null; } $trimmed = u($value)->trim()->toString(); return '' === $trimmed ? null : $trimmed; } }