Skip to content

Commit

Permalink
Rename HafasController
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin committed Dec 11, 2024
1 parent 6d086e7 commit 9d75e93
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/RefreshCurrentTrips.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\DataProviders\DataProviderFactory;
use App\DataProviders\DataProviderInterface;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\DataProviders\HafasStopoverService;
use App\Enum\TripSource;
use App\Exceptions\HafasException;
Expand All @@ -20,7 +20,7 @@ class RefreshCurrentTrips extends Command

private function getDataProvider(): DataProviderInterface {
// Probably only HafasController is needed here, because this Command is very Hafas specific
return (new DataProviderFactory)->create(HafasController::class);
return (new DataProviderFactory)->create(Hafas::class);
}

public function handle(): int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use JsonException;
use PDOException;

class HafasController extends Controller implements DataProviderInterface
class Hafas extends Controller implements DataProviderInterface
{

private function client(): PendingRequest {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/API/v1/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\DataProviders\DataProviderFactory;
use App\DataProviders\DataProviderInterface;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Models\OAuthClient;
use App\Models\User;
use Illuminate\Contracts\Auth\Authenticatable;
Expand Down Expand Up @@ -103,7 +103,7 @@ class Controller extends \App\Http\Controllers\Controller

public function __construct() {
// todo: set data provider based on user settings
$this->dataProvider = (new DataProviderFactory())->create(HafasController::class);
$this->dataProvider = (new DataProviderFactory())->create(Hafas::class);
}

public function sendResponse(
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/API/v1/TransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\API\v1;

use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Dto\Transport\Station as StationDto;
use App\Enum\Business;
use App\Enum\StatusVisibility;
Expand Down Expand Up @@ -513,7 +513,7 @@ public function setHome(int $stationId): JsonResponse {
*/
public function getTrainStationAutocomplete(string $query): JsonResponse {
try {
$trainAutocompleteResponse = (new TransportBackend(HafasController::class))->getTrainStationAutocomplete($query);
$trainAutocompleteResponse = (new TransportBackend(Hafas::class))->getTrainStationAutocomplete($query);
return $this->sendResponse($trainAutocompleteResponse);
} catch (HafasException) {
return $this->sendError("There has been an error with our data provider", 503);
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Frontend/Admin/CheckinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Frontend\Admin;

use App\DataProviders\DataProviderFactory;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Enum\Business;
use App\Enum\StatusVisibility;
use App\Enum\TravelType;
Expand Down Expand Up @@ -36,7 +36,7 @@ class CheckinController
* @deprecated adapt admin panel to api endpoints
*/
public static function lookupStation(string|int $query): Station {
$dataProvider = (new DataProviderFactory)->create(HafasController::class);
$dataProvider = (new DataProviderFactory)->create(Hafas::class);

//Lookup by station ibnr
if (is_numeric($query)) {
Expand Down Expand Up @@ -93,7 +93,7 @@ public static function getDeprecatedDepartures(
'next' => $when->clone()->addMinutes(15)
];

$departures = (new DataProviderFactory)->create(HafasController::class)->getDepartures(
$departures = (new DataProviderFactory)->create(Hafas::class)->getDepartures(
station: $station,
when: $when,
type: $travelType,
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Frontend/Admin/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\DataProviders\DataProviderFactory;
use App\DataProviders\DataProviderInterface;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Enum\EventRejectionReason;
use App\Exceptions\HafasException;
use App\Http\Controllers\Backend\Admin\EventController as AdminEventBackend;
Expand All @@ -25,7 +25,7 @@ class EventController extends Controller
private DataProviderInterface $dataProvider;

public function __construct(string $dataProvider = null) {
$dataProvider ??= HafasController::class;
$dataProvider ??= Hafas::class;
$this->dataProvider = (new DataProviderFactory())->create($dataProvider);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/FrontendTransportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Exceptions\HafasException;
use App\Http\Controllers\TransportController as TransportBackend;
use Illuminate\Http\JsonResponse;
Expand All @@ -15,7 +15,7 @@ class FrontendTransportController extends Controller
public function TrainAutocomplete(string $station): JsonResponse {
try {
//todo: adapt data provider to users preferences
$provider = new TransportBackend(HafasController::class);
$provider = new TransportBackend(Hafas::class);
$trainAutocompleteResponse = $provider->getTrainStationAutocomplete($station);
return response()->json($trainAutocompleteResponse);
} catch (HafasException $e) {
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/RefreshStopover.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Jobs;

use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\DataProviders\HafasStopoverService;
use App\Exceptions\HafasException;
use App\Models\Stopover;
Expand All @@ -27,6 +27,6 @@ public function __construct(Stopover $stopover) {
* @throws HafasException
*/
public function handle(): void {
(new HafasStopoverService(HafasController::class))->refreshStopover($this->stopover);
(new HafasStopoverService(Hafas::class))->refreshStopover($this->stopover);
}
}
4 changes: 2 additions & 2 deletions app/Repositories/CheckinHydratorRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Repositories;

use App\DataProviders\DataProviderFactory;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Exceptions\HafasException;
use App\Models\Event;
use App\Models\Station;
Expand All @@ -27,7 +27,7 @@ public function getOneStation(string $searchKey, string|int $id): ?Station {
*/
public function getHafasTrip(string $tripID, string $lineName): Trip {
// todo: create trip IDs with a prefix, to distinguish between different data providers
$dataProvider = (new DataProviderFactory)->create(HafasController::class);
$dataProvider = (new DataProviderFactory)->create(Hafas::class);

if (is_numeric($tripID)) {
$trip = Trip::where('id', $tripID)->where('linename', $lineName)->first();
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/StationSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\DataProviders\DataProviderFactory;
use App\DataProviders\DataProviderInterface;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Exceptions\HafasException;
use App\Http\Controllers\Frontend\Admin\CheckinController;
use App\Models\Station;
Expand All @@ -19,7 +19,7 @@ class StationSearchTest extends FeatureTestCase

public function setUp(): void {
parent::setUp();
$this->dataProvider = (new DataProviderFactory())->create(HafasController::class);
$this->dataProvider = (new DataProviderFactory())->create(Hafas::class);
}


Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Transport/BackendCheckinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\DataProviders\DataProviderFactory;
use App\DataProviders\DataProviderInterface;
use App\DataProviders\HafasController;
use App\DataProviders\Hafas;
use App\Enum\TravelType;
use App\Exceptions\CheckInCollisionException;
use App\Exceptions\HafasException;
Expand All @@ -27,7 +27,7 @@ class BackendCheckinTest extends FeatureTestCase

public function setUp(): void {
parent::setUp();
$this->dataProvider = (new DataProviderFactory())->create(HafasController::class);
$this->dataProvider = (new DataProviderFactory())->create(Hafas::class);
}

use RefreshDatabase;
Expand Down

0 comments on commit 9d75e93

Please sign in to comment.