wip: booking process, refactoring

This commit is contained in:
Björn Fromme
2025-07-16 19:37:17 +02:00
parent 47faa6b08e
commit eecea0abd1
43 changed files with 2269 additions and 366 deletions
+5 -5
View File
@@ -16,18 +16,18 @@ use Symfony\Component\Validator\Constraints as Assert;
class Address
{
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public string $street = '';
public ?string $street = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public string $postCode = '';
public ?string $postCode = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public string $city = '';
public ?string $city = null;
public string $district = '';
public ?string $district = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public string $country = '';
public ?string $country = null;
/**
* Converts the address to API payload format.
+6 -6
View File
@@ -22,7 +22,7 @@ class Booking
public ?float $price = null;
public ?\DateTimeImmutable $bookingDate = null;
public ?string $travelName = null;
public ?int $travelId = null;
public ?int $dateId = null;
public ?string $travelCode = null;
public ?\DateTimeImmutable $travelDate = null;
public ?Travel $travelData = null;
@@ -88,8 +88,8 @@ class Booking
* Filters additional services by group and participant index mapping.
* Returns services that are assigned to the specified participant.
*
* @param int $participantIndex The participant index to filter by
* @param mixed $group The service group(s) to filter by
* @param int $participantIndex The participant index to filter by
* @param mixed $group The service group(s) to filter by
*
* @return array<Service> The filtered services for the participant
*/
@@ -108,14 +108,14 @@ class Booking
* Finds the transportation service that matches the participant index
* and travel direction (e.g., 'H' for outbound, 'R' for return).
*
* @param int $participantIndex The participant index to search for
* @param string $direction The travel direction ('H' or 'R')
* @param int $participantIndex The participant index to search for
* @param string $direction The travel direction ('H' or 'R')
*
* @return Service|null The matching transportation service or null if not found
*/
public function getTransportationServiceForParticipantAndDirection(
int $participantIndex,
string $direction
string $direction,
): ?Service {
foreach ($this->transportationServices as $service) {
if ($service->direction !== $direction) {
+3 -3
View File
@@ -15,14 +15,14 @@ use Symfony\Component\Validator\Constraints as Assert;
*/
class Communication
{
public string $phone = '';
public ?string $phone = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public string $mobile = '';
public ?string $mobile = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
#[Assert\Email(message: 'Bitte eine gültige Adresse angeben', mode: 'strict', groups: ['personal_data'])]
public string $email = '';
public ?string $email = null;
public bool $newsletter = false;
+10 -10
View File
@@ -24,20 +24,20 @@ class PersonalData
public ?string $status = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['Default', 'personal_data'])]
public string $name = '';
public ?string $name = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['Default', 'personal_data'])]
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 = null;
public ?string $title = null;
public ?string $gender = null;
public ?string $nationality = null;
public ?string $height = null;
public ?string $shoeSize = null;
public ?string $weight = null;
public ?\DateTimeImmutable $dateOfBirth = null;
public string $remarks = '';
public ?string $remarks = null;
#[Assert\Valid(groups: ['personal_data'])]
public Address $address;
@@ -63,7 +63,7 @@ class PersonalData
{
// Ensure date of birth is populated
if (null === $dob = $this->dateOfBirth) {
$dob = new \DateTimeImmutable(self::DEFAULT_AGE_YEARS . ' years ago');
$dob = new \DateTimeImmutable(self::DEFAULT_AGE_YEARS.' years ago');
}
return [
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\BusProNet\Model;
use Symfony\Component\Serializer\Attribute\Groups;
class Product
{
#[Groups(['api:list'])]
public ?int $id = null;
#[Groups(['api:list'])]
public ?string $code = null;
#[Groups(['api:list'])]
public ?string $name = null;
}
+5 -5
View File
@@ -92,8 +92,8 @@ class Travel
* Filters additional services based on the provided group(s) and optionally
* by availability. Services are sorted alphabetically by label.
*
* @param mixed $group The service group(s) to filter by
* @param bool $availableOnly Whether to include only available services
* @param mixed $group The service group(s) to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted services array
*/
@@ -118,8 +118,8 @@ class Travel
* Filters transportation services based on travel direction and optionally
* by availability. Services are sorted by subtype.
*
* @param string $direction The travel direction to filter by
* @param bool $availableOnly Whether to include only available services
* @param string $direction The travel direction to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted transportation services
*/
@@ -193,7 +193,7 @@ class Travel
public function getAvailableRooms(): array
{
return array_filter($this->rooms, function (Room $room) {
return $room->available > 0 && $room->status === Constants::STATUS_AVAILABLE;
return $room->available > 0 && Constants::STATUS_AVAILABLE === $room->status;
});
}
}