fix: rename usecase

This commit is contained in:
Aymeric GUERACAGUE 2025-12-21 00:58:50 +01:00
parent 5879fbd146
commit 1e2679395f
Signed by: Superkooka
GPG Key ID: F78F2B172E894865
3 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -2,7 +2,7 @@
namespace App\Application\UseCase;
readonly class GetGamesCalendarRequest
readonly class GenerateGamesCalendarRequest
{
public function __construct(
/** @var string[] $teams */

View File

@ -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',