diff --git a/src/Application/UseCase/GetGamesCalendar.php b/src/Application/UseCase/GenerateGamesCalendar.php similarity index 93% rename from src/Application/UseCase/GetGamesCalendar.php rename to src/Application/UseCase/GenerateGamesCalendar.php index afecbc0..af62162 100644 --- a/src/Application/UseCase/GetGamesCalendar.php +++ b/src/Application/UseCase/GenerateGamesCalendar.php @@ -9,14 +9,14 @@ use Doctrine\ORM\EntityManagerInterface; use Spatie\IcalendarGenerator\Components\Calendar; use Spatie\IcalendarGenerator\Components\Event; -class GetGamesCalendar +class GenerateGamesCalendar { public function __construct( private readonly EntityManagerInterface $entityManager, ) { } - public function __invoke(GetGamesCalendarRequest $request): string + public function __invoke(GenerateGamesCalendarRequest $request): string { $calendar = Calendar::create() ->name('Game') @@ -56,7 +56,7 @@ class GetGamesCalendar $home = $this->entityManager->getRepository(Team::class)->find($game->homeTeamId) ?? throw new \Exception('Team not found'); $away = $this->entityManager->getRepository(Team::class)->find($game->awayTeamId) ?? throw new \Exception('Team not found'); - $events[] = Event::create($home->name . ' vs ' . $away->name) + $events[] = Event::create($away->name . ' vs ' . $home->name) ->startsAt($game->startTimeScheduled) ->endsAt($game->endTimeScheduled ?? $game->startTimeScheduled->modify('+3 hours')) // should be a parameter of the league ->address($game->venue); diff --git a/src/Application/UseCase/GetGamesCalendarRequest.php b/src/Application/UseCase/GenerateGamesCalendarRequest.php similarity index 78% rename from src/Application/UseCase/GetGamesCalendarRequest.php rename to src/Application/UseCase/GenerateGamesCalendarRequest.php index 4f7a2ff..47f64d7 100644 --- a/src/Application/UseCase/GetGamesCalendarRequest.php +++ b/src/Application/UseCase/GenerateGamesCalendarRequest.php @@ -2,7 +2,7 @@ namespace App\Application\UseCase; -readonly class GetGamesCalendarRequest +readonly class GenerateGamesCalendarRequest { public function __construct( /** @var string[] $teams */ diff --git a/src/Infrastructure/Controller/Calendar.php b/src/Infrastructure/Controller/Calendar.php index 6ba0438..56851f4 100644 --- a/src/Infrastructure/Controller/Calendar.php +++ b/src/Infrastructure/Controller/Calendar.php @@ -3,7 +3,7 @@ namespace App\Infrastructure\Controller; use App\Application\CommandBus\UseCaseCommandBus; -use App\Application\UseCase\GetGamesCalendarRequest; +use App\Application\UseCase\GenerateGamesCalendarRequest; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -17,7 +17,7 @@ class Calendar extends AbstractController public function getCalendar(Request $request): Response { - $calendar = $this->commandBus->ask(new GetGamesCalendarRequest($request->query->all('teams'))); + $calendar = $this->commandBus->ask(new GenerateGamesCalendarRequest($request->query->all('teams'))); return new Response($calendar, 200, [ 'Content-Type' => 'text/calendar; charset=utf-8',