Files
myep/src/BusProNet/Model/Address.php
T

51 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Represents a physical address with street, postal code, city, and country information.
*
* This class handles address data for users and participants in the booking system.
* It provides validation constraints for required fields and methods to convert
* address data to API payload format.
*/
class Address
{
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
public ?string $street = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
public ?string $postCode = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
public ?string $city = null;
public ?string $district = null;
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data', 'applicant_address'])]
public ?string $country = null;
/**
* 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<string, string> 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,
];
}
}