feat: refactoring and cleanup

This commit is contained in:
Björn Fromme
2026-03-16 11:59:12 +01:00
parent 230c53875f
commit 8c8aae9a1e
41 changed files with 2591 additions and 2233 deletions
+70
View File
@@ -161,6 +161,9 @@ class BookingDto
return $this->participants;
}
/**
* @deprecated Use getParticipant() and check for null instead
*/
public function hasParticipant(int $index): bool
{
return isset($this->participants[$index]);
@@ -202,11 +205,17 @@ class BookingDto
return ($adults >= 1 && $adults <= 2) && ($children >= 1);
}
/**
* @deprecated Use ParticipantDto::isCanceled() instead
*/
public function isCanceled(): bool
{
return null !== $this->booking && 'S' === $this->booking->status;
}
/**
* @deprecated Use ParticipantDto::isOption() instead
*/
public function isOption(): bool
{
return null !== $this->booking && 'O' === $this->booking->status;
@@ -219,6 +228,8 @@ class BookingDto
* Used by templates to display the room assignment when the dropdown is hidden.
*
* @return string|null The room label or null if not a single room type scenario
*
* @deprecated No known usages
*/
public function getSingleRoomLabel(): ?string
{
@@ -284,6 +295,8 @@ class BookingDto
* Checks if any participants have entered voucher codes.
*
* @return bool True if any promotional, purchase, or goodwill vouchers are present
*
* @deprecated Use AcceptedVouchersDto::hasVouchers() instead
*/
public function hasVouchers(): bool
{
@@ -317,4 +330,61 @@ class BookingDto
return false;
}
/**
* Calculates the number of participants assigned to each room ID.
*
* @return array<int, int> Array where key is room ID and value is count of assigned participants
*/
public function getRoomAssignmentCounts(): array
{
$counts = [];
foreach ($this->participants as $participant) {
if (null !== $participant->assignedRoomId) {
$counts[$participant->assignedRoomId] = ($counts[$participant->assignedRoomId] ?? 0) + 1;
}
}
return $counts;
}
/**
* Resets all participant room assignments.
*
* Clears room assignments when room selections change to prevent
* invalid assignments.
*/
public function resetParticipantAssignments(): void
{
foreach ($this->participants as $participant) {
$participant->assignedRoomId = null;
}
}
/**
* Creates a snapshot of the current room selection state.
*
* @return array<int, array{int, int}> Array of [roomId, quantity] pairs
*/
public function createRoomSelectionSnapshot(): array
{
return array_map(
fn ($roomSelection) => [(int) $roomSelection->roomId, (int) $roomSelection->quantity],
$this->roomSelections
);
}
/**
* Checks if room selection has changed compared to a previous snapshot.
*
* @param array<int, array{int, int}> $oldSnapshot The baseline room selection snapshot
*
* @return bool True if room selections have changed, false otherwise
*/
public function hasRoomSelectionChanged(array $oldSnapshot): bool
{
$newSnapshot = $this->createRoomSelectionSnapshot();
return $oldSnapshot !== $newSnapshot;
}
}