address = new Address(); $this->communication = new Communication(); } /** * Converts the personal data to API payload format. * * Transforms the personal data 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 { // Ensure date of birth is populated if (null === $dob = $this->dateOfBirth) { $dob = new \DateTimeImmutable(self::DEFAULT_AGE_YEARS.' years ago'); } return [ 'idadresse' => $this->addressId, 'idadresseperson' => $this->personId, 'geburtsdatum' => $dob->format('d.m.Y'), 'anrede' => $this->salutation, 'geschlecht' => $this->gender, 'nationalitaet' => $this->nationality, 'titel' => $this->title, 'vorname' => $this->firstName, 'name' => $this->name, 'anschrift' => $this->address->toPayload(), 'kommunikation' => $this->communication->toPayload(), 'sonstiges1' => $this->height, 'sonstiges2' => $this->weight, 'sonstiges3' => $this->shoeSize, 'bemerkung' => $this->remarks, ]; } /** * Extracts user claims for authentication and profile information. * * Creates a structured array containing user profile information * suitable for JWT claims or user session data. * * @return array The claims array with user profile data */ public function getClaims(): array { return [ 'email' => $this->communication->email, 'profile' => [ 'first_name' => $this->firstName, 'last_name' => $this->name, 'title' => $this->title, 'salutation' => $this->salutation, 'gender' => $this->gender, 'nationality' => $this->nationality, 'address' => [ 'street' => $this->address->street, 'postcode' => $this->address->postCode, 'city' => $this->address->city, 'disctrict' => $this->address->district, 'country' => $this->address->country, ], 'communication' => [ 'email' => $this->communication->email, 'mobile' => $this->communication->mobile, 'phone' => $this->communication->phone, 'newsletter' => $this->communication->newsletter, ], 'height' => $this->height, 'weight' => $this->weight, 'shoe_size' => $this->shoeSize, 'remarks' => $this->remarks, ], ]; } }