-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚑 add fallback for departures / journeys (#3104)
Co-authored-by: Levin <[email protected]>
- Loading branch information
1 parent
bbd9e1c
commit 83c89dc
Showing
11 changed files
with
326 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Dto\Transport; | ||
|
||
use App\Models\Trip; | ||
use Carbon\Carbon; | ||
|
||
readonly class Departure { | ||
|
||
public \App\Models\Station $station; | ||
public Carbon $plannedDeparture; | ||
public Carbon|null $realDeparture; | ||
public Trip $trip; | ||
|
||
public function __construct(\App\Models\Station $station, Carbon $plannedDeparture, Carbon|null $realDeparture, Trip $trip) { | ||
$this->station = $station; | ||
$this->plannedDeparture = $plannedDeparture; | ||
$this->realDeparture = $realDeparture; | ||
$this->trip = $trip; | ||
} | ||
|
||
public function getDelay(): ?int { | ||
if($this->realDeparture === null) { | ||
return null; | ||
} | ||
return $this->plannedDeparture->diffInMinutes($this->realDeparture); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace App\Enum; | ||
|
||
enum ReiseloesungCategory: string | ||
{ | ||
case ICE = 'ICE'; | ||
case EC_IC = 'EC_IC'; | ||
case IR = 'IR'; | ||
case REGIONAL = 'REGIONAL'; | ||
case SBAHN = 'SBAHN'; | ||
case BUS = 'BUS'; | ||
case SCHIFF = 'SCHIFF'; | ||
case UBAHN = 'UBAHN'; | ||
case TRAM = 'TRAM'; | ||
case ANRUFPFLICHTIG = 'ANRUFPFLICHTIG'; | ||
case UNKNOWN = 'UNKNOWN'; | ||
|
||
|
||
public function getHTT(): HafasTravelType { | ||
return match ($this->name) { | ||
'ICE' => HafasTravelType::NATIONAL_EXPRESS, | ||
'EC_IC' => HafasTravelType::NATIONAL, | ||
'IR' => HafasTravelType::REGIONAL_EXP, | ||
'UNKNOWN', 'REGIONAL' => HafasTravelType::REGIONAL, | ||
'SBAHN' => HafasTravelType::SUBURBAN, | ||
'BUS' => HafasTravelType::BUS, | ||
'SCHIFF' => HafasTravelType::FERRY, | ||
'UBAHN' => HafasTravelType::SUBWAY, | ||
'TRAM' => HafasTravelType::TRAM, | ||
'ANRUFPFLICHTIG' => HafasTravelType::TAXI, | ||
default => HafasTravelType::REGIONAL, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.