feat: refactoring and cleanup
This commit is contained in:
@@ -33,6 +33,8 @@ class AcceptedVouchersDto
|
||||
|
||||
/**
|
||||
* @return array<AcceptedVoucherDto>
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function getPromotionalVouchers(): array
|
||||
{
|
||||
@@ -41,6 +43,8 @@ class AcceptedVouchersDto
|
||||
|
||||
/**
|
||||
* @return array<AcceptedVoucherDto>
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function getPurchaseVouchers(): array
|
||||
{
|
||||
@@ -49,6 +53,8 @@ class AcceptedVouchersDto
|
||||
|
||||
/**
|
||||
* @return array<AcceptedVoucherDto>
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function getGoodwillVouchers(): array
|
||||
{
|
||||
@@ -65,6 +71,9 @@ class AcceptedVouchersDto
|
||||
return count($this->vouchers) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated No known usages
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->vouchers);
|
||||
|
||||
@@ -46,6 +46,8 @@ class BankAccountDto
|
||||
|
||||
/**
|
||||
* Returns IBAN formatted with spaces for display (e.g., DE12 3456 7890 1234 5678 90).
|
||||
*
|
||||
* @deprecated No known usages
|
||||
*/
|
||||
public function getFormattedIban(): ?string
|
||||
{
|
||||
@@ -60,6 +62,8 @@ class BankAccountDto
|
||||
|
||||
/**
|
||||
* Returns IBAN without spaces for storage and API submission.
|
||||
*
|
||||
* @deprecated Only used by getFormattedIban() which is also deprecated
|
||||
*/
|
||||
public function getIbanWithoutSpaces(): ?string
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Model;
|
||||
|
||||
/**
|
||||
* DTO containing all booking summary data for sidebar display.
|
||||
*
|
||||
* Provides pricing breakdowns, room assignments, participant counts,
|
||||
* and CMS product information in a single typed object.
|
||||
*/
|
||||
class BookingSummaryDto
|
||||
{
|
||||
/**
|
||||
* @param array<int, RoomSelectionDto> $selectedRooms Selected room DTOs from booking
|
||||
* @param int $participantCount Total participant count from room capacity
|
||||
* @param string $totalPrice Formatted total price (e.g., "1.234,56 €")
|
||||
* @param array<array{room: mixed, count: int}> $groupedSelectedRooms Rooms grouped by participant assignments
|
||||
* @param array<int, int> $assignmentCounts Room ID to participant count mapping
|
||||
* @param array $pricingData Detailed pricing breakdown
|
||||
* @param array|null $cmsData CMS product data (images, etc.)
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $selectedRooms,
|
||||
public readonly int $participantCount,
|
||||
public readonly string $totalPrice,
|
||||
public readonly array $groupedSelectedRooms,
|
||||
public readonly array $assignmentCounts,
|
||||
public readonly array $pricingData,
|
||||
public readonly ?array $cmsData,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,9 @@ class ParticipantDto
|
||||
return 'S' === $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated No known usages
|
||||
*/
|
||||
public function isOption(): bool
|
||||
{
|
||||
return 'O' === $this->status;
|
||||
@@ -237,6 +240,8 @@ class ParticipantDto
|
||||
* Checks if the participant has selected an insurance.
|
||||
*
|
||||
* @return bool True if an insurance is selected
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function hasInsuranceSelected(): bool
|
||||
{
|
||||
@@ -247,6 +252,8 @@ class ParticipantDto
|
||||
* Gets the insurance label for display purposes.
|
||||
*
|
||||
* @return string|null The insurance label or null if no insurance selected
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function getInsuranceLabel(): ?string
|
||||
{
|
||||
@@ -257,6 +264,8 @@ class ParticipantDto
|
||||
* Gets the insurance price for pricing calculations.
|
||||
*
|
||||
* @return float The insurance price (0.0 if no insurance selected)
|
||||
*
|
||||
* @deprecated No known usages outside tests
|
||||
*/
|
||||
public function getInsurancePrice(): float
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user