feat: extract room grouping from booking service
This commit is contained in:
1 parent
8b72f8c277
commit
f31ac660d2
8 files changed
+120
-136
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Room;
|
||||
|
||||
/**
|
||||
* Groups room data for booking steps.
|
||||
*/
|
||||
class BookingRoomSelectionService
|
||||
{
|
||||
/**
|
||||
* @param array<int, Room> $rooms
|
||||
*
|
||||
* @return array{by_pax: array<int, Room>, by_room: array<int, Room>}
|
||||
*/
|
||||
public function groupRoomsBySelectionType(array $rooms): array
|
||||
{
|
||||
$groups = [
|
||||
Room::SELECTION_TYPE_BY_PAX => [],
|
||||
Room::SELECTION_TYPE_BY_ROOM => [],
|
||||
];
|
||||
|
||||
foreach ($rooms as $room) {
|
||||
if (false !== stripos($room->label, 'bett')) {
|
||||
$groups[Room::SELECTION_TYPE_BY_PAX][$room->id] = $room;
|
||||
continue;
|
||||
}
|
||||
|
||||
$groups[Room::SELECTION_TYPE_BY_ROOM][$room->id] = $room;
|
||||
}
|
||||
|
||||
uasort($groups[Room::SELECTION_TYPE_BY_PAX], static fn (Room $a, Room $b): int => $a->maxPax <=> $b->maxPax);
|
||||
uasort($groups[Room::SELECTION_TYPE_BY_ROOM], static fn (Room $a, Room $b): int => $a->maxPax <=> $b->maxPax);
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user