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

93 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
/**
* Represents a room configuration with capacity, pricing, and availability information.
*
* This class handles room data including category, board options, capacity limits,
* pricing structure, and participant mapping. It provides serialization groups
* for different API contexts and booking management.
*/
class Room
{
public const SELECTION_TYPE_BY_PAX = 'by_pax';
public const SELECTION_TYPE_BY_ROOM = 'by_room';
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $id = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?string $category = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $boardId = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?string $code = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?string $label = null;
#[Groups(['booking'])]
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
public ?\DateTimeImmutable $dateFrom = null;
#[Groups(['booking'])]
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
public ?\DateTimeImmutable $dateTo = null;
#[Groups(['booking'])]
public ?int $totalCount = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $minPax = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $maxPax = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $nights = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?string $status = null;
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?int $available = null;
#[Groups(['booking'])]
public ?string $board = null;
#[Groups(['booking'])]
public array $mapping = [];
#[Groups(['api:list', 'api:single', 'snapshot'])]
public ?float $price = null;
#[Groups(['booking'])]
public ?float $totalPrice = null;
#[Groups(['booking'])]
public array $individualPrice = [];
/**
* Determines the selection type of the room based on its label.
*
* @return string Either self::SELECTION_TYPE_BY_PAX or self::SELECTION_TYPE_BY_ROOM
*/
public function getSelectionType(): string
{
if (1 === preg_match('/bett/i', $this->label)) {
return self::SELECTION_TYPE_BY_PAX;
}
return self::SELECTION_TYPE_BY_ROOM;
}
}