wip: courses

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent b54fb07e84
commit 4b92f56ed7
6 changed files with 38 additions and 11 deletions
+8 -6
View File
@@ -95,14 +95,15 @@ class Travel
* @param mixed $group The service group(s) to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted services array
* @return array<int, Service> The filtered and sorted services array
*/
public function getAdditionalServicesByGroup(mixed $group, bool $availableOnly = true): array
{
$group = (array) $group;
$services = array_filter($this->additionalServices, function (Service $service) use ($group, $availableOnly) {
return true === in_array($service->subType, $group) && (false === $availableOnly || 0 < $service->available);
return true === in_array($service->subType, $group)
&& (false === $availableOnly || 0 < $service->available || null === $service->available);
});
usort($services, function (Service $a, Service $b) {
@@ -121,14 +122,14 @@ class Travel
* @param string $direction The travel direction to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted transportation services
* @return array<int, Service> The filtered and sorted transportation services
*/
public function getTransportationServicesByDirection(string $direction, bool $availableOnly = true): array
{
$services = array_filter($this->transportationServices, function (Service $service) use ($direction, $availableOnly) {
return $direction === $service->direction
&& $service->price >= 0
&& (false === $availableOnly || $service->available > 0);
&& (false === $availableOnly || $service->available > 0 || null === $service->available);
});
usort($services, function (Service $a, Service $b) {
@@ -144,7 +145,7 @@ class Travel
* Maps selection group IDs to their corresponding services based on
* the predefined included services mapping.
*
* @return array The included services from selection groups
* @return array<int, Service> The included services from selection groups
*/
public function getIncludedServices(): array
{
@@ -168,7 +169,7 @@ class Travel
*
* @param array<int> $ids The array of room IDs to filter by
*
* @return array<Room> The filtered rooms array
* @return array<int, Room> The filtered rooms array
*/
public function getRoomsByIds(array $ids): array
{
@@ -198,6 +199,7 @@ class Travel
$result[$room->id] = $room;
}
}
return $result;
}
}