feat: travel data API endpoint for travelinfo pages in TYPO3

This commit is contained in:
Björn Fromme
2025-05-15 11:54:37 +02:00
parent 1e5401ea25
commit 6bf22045c4
6 changed files with 120 additions and 9 deletions
@@ -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);
}
}