wip: booking process

This commit is contained in:
Björn Fromme
2025-07-14 17:15:15 +02:00
parent a55e30e12d
commit bef18971c3
45 changed files with 688 additions and 270 deletions
+42 -14
View File
@@ -1,31 +1,43 @@
<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Represents personal data for a user including address and communication information.
*
* This class handles the storage and transformation of personal information
* including name, address, communication details, and physical attributes.
* It provides methods to convert data to API payload format and extract claims
* for authentication purposes.
*/
class PersonalData
{
private const DEFAULT_AGE_YEARS = 18;
public ?int $addressId = null;
public ?int $personId = null;
public bool $mutable = false;
public ?string $status = '';
public ?string $status = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['Default', 'personal_data'])]
public ?string $name = '';
public string $name = '';
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['Default', 'personal_data'])]
public ?string $firstName = '';
public string $firstName = '';
public ?string $salutation = '';
public ?string $title = '';
public ?string $gender = '';
public ?string $nationality = '';
public ?string $height = '';
public ?string $shoeSize = '';
public ?string $weight = '';
public string $salutation = '';
public string $title = '';
public string $gender = '';
public string $nationality = '';
public string $height = '';
public string $shoeSize = '';
public string $weight = '';
public ?\DateTimeImmutable $dateOfBirth = null;
public ?string $remarks = '';
public string $remarks = '';
#[Assert\Valid(groups: ['personal_data'])]
public Address $address;
@@ -39,11 +51,19 @@ class PersonalData
$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<string, mixed> The payload array for API transmission
*/
public function toPayload(): array
{
// Ensure date of birth is populated
if (null === $dob = $this->dateOfBirth) {
$dob = new \DateTimeImmutable('18 years ago');
$dob = new \DateTimeImmutable(self::DEFAULT_AGE_YEARS . ' years ago');
}
return [
@@ -56,8 +76,8 @@ class PersonalData
'titel' => $this->title,
'vorname' => $this->firstName,
'name' => $this->name,
'anschrift' => $this->address?->toPayload(),
'kommunikation' => $this->communication?->toPayload(),
'anschrift' => $this->address->toPayload(),
'kommunikation' => $this->communication->toPayload(),
'sonstiges1' => $this->height,
'sonstiges2' => $this->weight,
'sonstiges3' => $this->shoeSize,
@@ -65,6 +85,14 @@ class PersonalData
];
}
/**
* 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<string, mixed> The claims array with user profile data
*/
public function getClaims(): array
{
return [