feat: travel data API endpoint for travelinfo pages in TYPO3
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Utility;
|
||||
|
||||
class TravelCodeUtility
|
||||
{
|
||||
public function sanitize(string $travelCode): string
|
||||
{
|
||||
return str_replace(['-', '/'], '', strtoupper($travelCode));
|
||||
}
|
||||
|
||||
public function getBaseCode(string $travelCode): string
|
||||
{
|
||||
return strtoupper(substr($travelCode, 0, -6));
|
||||
}
|
||||
|
||||
public function getDate(string $travelCode): \DateTimeImmutable
|
||||
{
|
||||
$datePart = substr($travelCode, -6);
|
||||
|
||||
return \DateTimeImmutable::createFromFormat('dmy', $datePart);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user