*/ public array $roles = []; /** @var list */ public array $hotelCodes = []; public function __construct() { $this->address = new Address(); $this->communication = new Communication(); } public function getFullName(): string { return sprintf('%s %s', $this->firstName, $this->name); } /** * 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(bool $includeDateOfBirth = true): array { $payload = [ 'idadresse' => $this->addressId, 'idadresseperson' => $this->personId, '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, ]; if (true === $includeDateOfBirth) { $dob = $this->dateOfBirth ?? new \DateTimeImmutable(self::DEFAULT_AGE_YEARS.' years ago'); $payload['geburtsdatum'] = $dob->format('d.m.Y'); } return $payload; } public static function fromContactFormSubmission(ContactFormSubmission $dto): self { $gender = null !== $dto->gender ? strtoupper($dto->gender) : null; if ('F' === $gender) { $gender = 'W'; } $instance = new self(); $instance->name = $dto->lastName; $instance->firstName = $dto->firstName; $instance->gender = $gender; $instance->address->street = $dto->street; $instance->address->postCode = $dto->zipCode; $instance->address->city = $dto->city; $instance->communication->email = $dto->email; $instance->communication->phone = $dto->phone; return $instance; } /** * 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 [ 'id' => $this->personId, 'email' => $this->communication->email, 'roles' => $this->roles, 'profile' => [ 'first_name' => $this->firstName, 'last_name' => $this->name, 'title' => $this->title, 'salutation' => $this->salutation, 'gender' => $this->gender, 'date_of_birth' => $this->dateOfBirth?->format('Y-m-d'), 'nationality' => $this->nationality, 'address' => [ 'street' => $this->address->street, 'postcode' => $this->address->postCode, 'city' => $this->address->city, 'district' => $this->address->district, 'country' => $this->address->country, ], 'communication' => [ 'email' => $this->communication->email, 'mobile' => $this->communication->mobile, 'phone' => $this->communication->phone, 'newsletter' => $this->communication->newsletter, ], 'hotel_codes' => $this->hotelCodes, 'height' => $this->height, 'weight' => $this->weight, 'shoe_size' => $this->shoeSize, 'remarks' => $this->remarks, ], ]; } }