159 lines
4.7 KiB
PHP
159 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace App\Data;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Contracts\Support\Arrayable;
|
|
use Illuminate\Support\Collection;
|
|
|
|
enum AttractionTypeTag: string
|
|
{
|
|
case Children = 'ATTRACTION_TYPE_CHILDREN';
|
|
case MindTheSizeChart = 'ATTRACTION_TYPE_MIND_THE_SIZE_CHART';
|
|
case Family = 'ATTRACTION_TYPE_FAMILY';
|
|
case Roofed = 'ATTRACTION_TYPE_ROOFED';
|
|
case Pictures = 'ATTRACTION_TYPE_PICTURES';
|
|
case QuickPass = 'ATTRACTION_TYPE_QUICK_PASS';
|
|
case Action = 'ATTRACTION_TYPE_ACTION';
|
|
case QuickPassPlus = 'ATTRACTION_TYPE_QUICK_PASS_PLUS';
|
|
case SingleRiderLine = 'ATTRACTION_TYPE_SINGLE_RIDER_LINE';
|
|
case Water = 'ATTRACTION_TYPE_WATER';
|
|
case NoOperationSubNegative5 = 'ATTRACTION_NO_OPERATION_SUB_NEGATIVE_5';
|
|
case NoOperationSubZero = 'ATTRACTION_NO_OPERATION_SUB_ZERO';
|
|
case ChildrenMayScare = 'ATTRACTION_TYPE_CHILDREN_MAY_SCARE';
|
|
}
|
|
|
|
enum AttractionTypeEmote: string
|
|
{
|
|
case Children = '👶';
|
|
case MindTheSizeChart = '📏';
|
|
case Family = '👨👩👧👦';
|
|
case Roofed = '🏠';
|
|
case Pictures = '📸';
|
|
case QuickPass = '🎟️';
|
|
case Action = '🔥';
|
|
case QuickPassPlus = '🎟️+';
|
|
case SingleRiderLine = '🚶♂️';
|
|
case Water = '💧';
|
|
case NoOperationSubNegative5 = '🚫 -5';
|
|
case NoOperationSubZero = '🚫 0';
|
|
case ChildrenMayScare = '👻';
|
|
}
|
|
|
|
enum AttractionTypeTagDescription: string
|
|
{
|
|
case Children = 'Attraktion für Kinder';
|
|
case MindTheSizeChart = 'Achtung Größenbeschränkung';
|
|
case Family = 'Attraktion für die ganze Familie';
|
|
case Roofed = 'Überdachte Attraktion';
|
|
case Pictures = 'Attraktion mit Fotomöglichkeit';
|
|
case QuickPass = 'Attraktion mit Quick Pass';
|
|
case Action = 'Actionreiche Attraktion';
|
|
case QuickPassPlus = 'Attraktion mit Quick Pass Plus';
|
|
case SingleRiderLine = 'Attraktion mit Single Rider Line';
|
|
case Water = 'Wasserattraktion';
|
|
case NoOperationSubNegative5 = 'Attraktion hat bei -5°C oder kälter geschlossen';
|
|
case NoOperationSubZero = 'Attraktion hat bei 0°C oder kälter geschlossen';
|
|
case ChildrenMayScare = 'Attraktion könnte Kinder erschrecken';
|
|
|
|
}
|
|
|
|
readonly class PointOfInterest implements Arrayable
|
|
{
|
|
private readonly array $info;
|
|
function __construct
|
|
(
|
|
public int $id,
|
|
public ?int $poiNumber,
|
|
public ?int $poiNumberWinter,
|
|
public string $category,
|
|
public array $tags,
|
|
public string $area,
|
|
public array $seasons,
|
|
public string $title,
|
|
public ?string $description,
|
|
public array $entrance,
|
|
public ?string $titleImage,
|
|
)
|
|
{
|
|
|
|
}
|
|
|
|
public function setInfo(array $info): void
|
|
{
|
|
$this->info = $info;
|
|
}
|
|
|
|
public function queueTime(): int
|
|
{
|
|
return $this?->info['waitTime'] ?? 0;
|
|
}
|
|
|
|
public function isOpen(): bool
|
|
{
|
|
$now = now()->setTimezone('Europe/Berlin');
|
|
$inOpeningHours = $now->between($this->opensAt(), $this->closesAt());
|
|
|
|
$rideOpen = $this->info['open'];
|
|
|
|
if(!$rideOpen) {
|
|
return false;
|
|
}
|
|
|
|
return $inOpeningHours;
|
|
}
|
|
|
|
public function closesAt(): Carbon
|
|
{
|
|
return Carbon::parse($this->info['closing'], 'Europe/Berlin');
|
|
}
|
|
|
|
public function opensAt(): Carbon
|
|
{
|
|
return Carbon::parse($this->info['opening'], 'Europe/Berlin');
|
|
}
|
|
|
|
public function hasTag(AttractionTypeTag $tag): bool
|
|
{
|
|
return in_array($tag, $this->tags);
|
|
}
|
|
|
|
public function getTagEmote(AttractionTypeTag $tag): AttractionTypeEmote
|
|
{
|
|
$emotes = collect(AttractionTypeEmote::cases());
|
|
$emote = $emotes->first(fn($emote) => $emote->name === $tag->name);
|
|
return $emote;
|
|
}
|
|
|
|
public function getTags(): Collection
|
|
{
|
|
return collect($this->tags)->map(function ($tag) {
|
|
return AttractionTypeTag::from($tag);
|
|
});
|
|
}
|
|
|
|
public function getTagDescription(AttractionTypeTag $tag): string
|
|
{
|
|
$descriptions = collect(AttractionTypeTagDescription::cases());
|
|
$description = $descriptions->first(fn($description) => $description->name === $tag->name);
|
|
return $description->value;
|
|
}
|
|
|
|
public function toArray()
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'poiNumber' => $this->poiNumber,
|
|
'poiNumberWinter' => $this->poiNumberWinter,
|
|
'category' => $this->category,
|
|
'tags' => $this->tags,
|
|
'area' => $this->area,
|
|
'seasons' => $this->seasons,
|
|
'title' => $this->title,
|
|
'description' => $this->description,
|
|
'entrance' => $this->entrance,
|
|
'titleImage' => $this->titleImage,
|
|
];
|
|
}
|
|
}
|