42 lines
984 B
PHP
42 lines
984 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Enum;
|
|
|
|
/**
|
|
* The accommodation type of a TYPO3 hotel record (`type` in the content feed), as the
|
|
* website's travel search filters it ("Unterkunft"). Values and labels follow the website's
|
|
* Hotel::$typeLabels.
|
|
*/
|
|
enum HotelType: int
|
|
{
|
|
case HolidayFlat = 1;
|
|
case SportsClub = 2;
|
|
case Apartment = 3;
|
|
case GuestHouse = 4;
|
|
case Pension = 5;
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::HolidayFlat => 'Ferienwohnung',
|
|
self::SportsClub => 'Sportclub',
|
|
self::Apartment => 'Apartment',
|
|
self::GuestHouse => 'Gästehaus',
|
|
self::Pension => 'Pension',
|
|
};
|
|
}
|
|
|
|
public static function fromLabel(string $label): ?self
|
|
{
|
|
foreach (self::cases() as $case) {
|
|
if (0 === strcasecmp($case->label(), trim($label))) {
|
|
return $case;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|