Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerrialn committed May 7, 2024
1 parent 8af7133 commit 5231461
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 97 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"scripts": {
"rector": "vendor/bin/rector p --ansi",
"rector-dry": "vendor/bin/rector p --dry-run --ansi",
"phpstan": "php -d memory_limit=256M vendor/bin/phpstan analyze",
"ps": "php -d memory_limit=256M vendor/bin/phpstan analyze",
"check-cs": "vendor/bin/ecs check --ansi",
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"test": "vendor/bin/phpunit",
Expand Down
43 changes: 19 additions & 24 deletions src/Controller/Controller/Event/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use App\DataTransferObject\Event\EventDetailsFormDto;
use App\DataTransferObject\Event\EventLocationFormDto;
use App\Entity\Event\Category;
use App\Entity\Event\Event;
use App\Entity\Event\EventEmailInvitation;
use App\Entity\Event\EventMoment;
Expand Down Expand Up @@ -51,21 +50,20 @@ class EventController extends AbstractController
public const EVENT_FORM_STEP_TWO = 'location';

public function __construct(
private readonly EventRepository $eventRepository,
private readonly ImageService $imageUploadService,
private readonly ImageFactory $imageFactory,
private readonly ImageCollectionFactory $imageCollectionFactory,
private readonly ImageCollectionRepository $imageCollectionRepository,
private readonly EventOrganiserFactory $eventCrewMemberFactory,
private readonly EventRoleRepository $eventRoleRepository,
private readonly EventFactory $eventFactory,
private readonly EventCancellationFactory $eventCancellationFactory,
private readonly TranslatorInterface $translator,
private readonly EventRepository $eventRepository,
private readonly ImageService $imageUploadService,
private readonly ImageFactory $imageFactory,
private readonly ImageCollectionFactory $imageCollectionFactory,
private readonly ImageCollectionRepository $imageCollectionRepository,
private readonly EventOrganiserFactory $eventCrewMemberFactory,
private readonly EventRoleRepository $eventRoleRepository,
private readonly EventFactory $eventFactory,
private readonly EventCancellationFactory $eventCancellationFactory,
private readonly TranslatorInterface $translator,
private readonly EventEmailInvitationRepository $eventEmailInvitationRepository,
private readonly EventInvitationRepository $eventInvitationRepository,
private readonly RequestStack $requestStack,
)
{
private readonly EventInvitationRepository $eventInvitationRepository,
private readonly RequestStack $requestStack,
) {
}

/**
Expand All @@ -88,7 +86,7 @@ public function edit(Event $event, Request $request): Response
if ($eventForm->isSubmitted() && $eventForm->isValid()) {
$image = $eventForm->get('image')->getData();

if (!empty($image)) {
if (! empty($image)) {
/** @var Event $event */
$event = $eventForm->getData();
$event->setBase64Image(
Expand Down Expand Up @@ -134,7 +132,7 @@ public function show(Request $request, Event $event, #[CurrentUser] null|User $c
]);
$invitations = $invitations->matching($criteria);

if (!empty($event->getUrl())) {
if (! empty($event->getUrl())) {
return $this->render('events/show-external-event.html.twig', [
'event' => $event,
]);
Expand Down Expand Up @@ -200,7 +198,6 @@ public function cancelEvent(Event $event, Request $request, #[CurrentUser] User
#[Route(path: '/events/create/{step}', name: 'create_event')]
public function create(Request $request, #[CurrentUser] User $currentUser, string $step): Response
{

$handle = $this->handleStep($step);
if ($handle instanceof Response) {
return $handle;
Expand All @@ -216,7 +213,6 @@ public function create(Request $request, #[CurrentUser] User $currentUser, strin

$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {

return match (true) {
$step === self::EVENT_FORM_STEP_ONE => $this->handleEventFormStepOne($form),
$step === self::EVENT_FORM_STEP_TWO => $this->handleEventFormStepTwo($form, $currentUser),
Expand Down Expand Up @@ -254,19 +250,18 @@ private function renderEventFormStepOne(): FormInterface
{
$eventDetailsFormDto = $this->requestStack->getSession()->get('event-form-step-one');

if (!$eventDetailsFormDto instanceof EventDetailsFormDto) {
if (! $eventDetailsFormDto instanceof EventDetailsFormDto) {
$eventDetailsFormDto = new EventDetailsFormDto();
}


return $this->createForm(EventDetailsFormType::class, $eventDetailsFormDto);
}

private function renderEventFormStepTwo(): FormInterface
{
$eventLocationFormDto = $this->requestStack->getSession()->get('event-form-step-two');

if (!$eventLocationFormDto instanceof EventLocationFormDto) {
if (! $eventLocationFormDto instanceof EventLocationFormDto) {
$eventLocationFormDto = new EventLocationFormDto();
}

Expand All @@ -275,7 +270,7 @@ private function renderEventFormStepTwo(): FormInterface

private function handleEventFormStepOne(FormInterface $form): Response
{
if (!empty($form->get('image')->getData())) {
if (! empty($form->get('image')->getData())) {
$base64Image = $this->imageUploadService->processPhoto($form->get('image')->getData());
$form->getData()->setBase64image($base64Image->getEncoded());
}
Expand Down Expand Up @@ -329,7 +324,7 @@ private function validateStepOne(): null|Response
{
$eventDetailsFormDto = $this->requestStack->getSession()->get('event-form-step-one');

if (!$eventDetailsFormDto instanceof EventDetailsFormDto) {
if (! $eventDetailsFormDto instanceof EventDetailsFormDto) {
return $this->redirectToRoute('create_event', [
'step' => self::EVENT_FORM_STEP_ONE,
]);
Expand Down
2 changes: 0 additions & 2 deletions src/DataTransferObject/Event/EventDetailsFormDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\DataTransferObject\Event;

use App\Entity\Event\Category;
use App\Entity\EventGroup\EventGroup;
use Carbon\CarbonImmutable;
use DateTimeImmutable;
Expand Down Expand Up @@ -123,5 +122,4 @@ public function setCategories(ArrayCollection $categories): void
{
$this->categories = $categories;
}

}
71 changes: 35 additions & 36 deletions src/Entity/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,31 +98,30 @@ class Event implements Stringable

public function __construct(
#[ORM\Column(length: 255)]
private null|string $title = null,
private null|string $title = null,
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private null|CarbonImmutable $startAt = null,
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
private null|CarbonImmutable $endAt = null,
#[ORM\Column(type: Types::TEXT, nullable: true)]
private null|string $description = null,
private null|string $description = null,
#[ORM\Column(type: 'decimal', precision: 10, scale: 7, nullable: true)]
private null|string $latitude = null,
private null|string $latitude = null,
#[ORM\Column(type: 'decimal', precision: 10, scale: 7, nullable: true)]
private null|string $longitude = null,
private null|string $longitude = null,
#[ORM\Column(type: Types::TEXT, nullable: true)]
private null|string $base64Image = null,
private null|string $base64Image = null,
#[ORM\Column]
private null|bool $isPrivate = false,
private null|bool $isPrivate = false,
#[ORM\Column(length: 255)]
private null|string $address = null,
private null|string $address = null,
#[ORM\ManyToOne(inversedBy: 'authoredEvents')]
#[ORM\JoinColumn(nullable: false)]
private ?User $owner = null,
private ?User $owner = null,
#[ORM\ManyToOne(inversedBy: 'events')]
#[ORM\JoinColumn(nullable: true)]
private null|EventGroup $eventGroup = null,
)
{
private null|EventGroup $eventGroup = null,
) {
$this->categories = new ArrayCollection();
$this->images = new ArrayCollection();
$this->eventOrganisers = new ArrayCollection();
Expand All @@ -141,7 +140,7 @@ public function __construct(

public function __toString(): string
{
return (string)$this->getTitle();
return (string) $this->getTitle();
}

public function getId(): null|Uuid
Expand Down Expand Up @@ -205,7 +204,7 @@ public function getCategories(): Collection

public function addCategory(Category $category): static
{
if (!$this->categories->contains($category)) {
if (! $this->categories->contains($category)) {
$this->categories->add($category);
}

Expand Down Expand Up @@ -310,7 +309,7 @@ public function getEventParticipants(): Collection

public function addEventParticipant(EventParticipant $user): self
{
if (!$this->getEventParticipants()->contains($user)) {
if (! $this->getEventParticipants()->contains($user)) {
$this->eventParticipants->add($user);
$user->setEvent($this);
}
Expand All @@ -328,7 +327,7 @@ public function removeEventParticipant(EventParticipant $user): self

public function addEventRequest(EventRequest $eventRequest): self
{
if (!$this->getEventRequests()->contains($eventRequest)) {
if (! $this->getEventRequests()->contains($eventRequest)) {
$this->eventRequests->add($eventRequest);
$eventRequest->setEvent($this);
}
Expand All @@ -353,7 +352,7 @@ public function getEventInvitations(): Collection

public function addEventInvitation(EventInvitation $eventInvite): self
{
if (!$this->getEventParticipants()->exists(fn(int $key, EventParticipant $eventParticipant) => $eventParticipant->getEvent() === $eventInvite->getEvent() && $eventParticipant->getOwner() === $eventInvite->getTarget()) && !$this->eventInvitations->exists(fn(int $key, EventInvitation $existingEventInvite) => $existingEventInvite->getEvent() === $eventInvite->getEvent() && $existingEventInvite->getTarget() === $eventInvite->getTarget())) {
if (! $this->getEventParticipants()->exists(fn (int $key, EventParticipant $eventParticipant) => $eventParticipant->getEvent() === $eventInvite->getEvent() && $eventParticipant->getOwner() === $eventInvite->getTarget()) && ! $this->eventInvitations->exists(fn (int $key, EventInvitation $existingEventInvite) => $existingEventInvite->getEvent() === $eventInvite->getEvent() && $existingEventInvite->getTarget() === $eventInvite->getTarget())) {
$this->eventInvitations->add($eventInvite);
$eventInvite->setEvent($this);
}
Expand Down Expand Up @@ -381,7 +380,7 @@ public function getEventRejections(): Collection

public function addEventRejection(EventRejection $eventRejection): self
{
if (!$this->getEventRejections()->contains($eventRejection)) {
if (! $this->getEventRejections()->contains($eventRejection)) {
$this->eventRejections->add($eventRejection);
$eventRejection->setEvent($this);
}
Expand All @@ -408,7 +407,7 @@ public function getImages(): Collection

public function addImage(Image $image): static
{
if (!$this->images->contains($image)) {
if (! $this->images->contains($image)) {
$this->images->add($image);
}

Expand Down Expand Up @@ -436,7 +435,7 @@ public function getEventOrganisers(): Collection

public function addEventOrganiser(EventOrganiser $eventOrganiser): static
{
if (!$this->getEventOrganisers()->contains($eventOrganiser)) {
if (! $this->getEventOrganisers()->contains($eventOrganiser)) {
$this->eventOrganisers->add($eventOrganiser);
$eventOrganiser->setEvent($this);
}
Expand Down Expand Up @@ -478,7 +477,7 @@ public function getImageCollections(): Collection

public function addImageCollection(ImageCollection $imageCollection): static
{
if (!$this->getImageCollections()->contains($imageCollection)) {
if (! $this->getImageCollections()->contains($imageCollection)) {
$this->imageCollections->add($imageCollection);
$imageCollection->setEvent($this);
}
Expand Down Expand Up @@ -528,7 +527,7 @@ public function getEventEmailInvitations(): Collection

public function addEmailInvitation(EventEmailInvitation $emailInvitation): static
{
if (!$this->getEventEmailInvitations()->contains($emailInvitation)) {
if (! $this->getEventEmailInvitations()->contains($emailInvitation)) {
$this->eventEmailInvitations->add($emailInvitation);
$emailInvitation->setEvent($this);
}
Expand Down Expand Up @@ -567,7 +566,7 @@ public function getTitleAndDate(): string

public function getUnansweredInvitation(User $user): null|EventInvitation
{
return $this->getEventInvitations()->findFirst(fn(int $key, EventInvitation $eventInvitation) => $eventInvitation->getTarget() === $user);
return $this->getEventInvitations()->findFirst(fn (int $key, EventInvitation $eventInvitation) => $eventInvitation->getTarget() === $user);
}

public function getAddress(): null|string
Expand Down Expand Up @@ -638,7 +637,7 @@ public function getEventOrganiserInvitations(): Collection

public function addEventOrganiserInvitation(EventOrganiserInvitation $eventOrganiserInvitation): static
{
if (!$this->eventOrganiserInvitations->contains($eventOrganiserInvitation)) {
if (! $this->eventOrganiserInvitations->contains($eventOrganiserInvitation)) {
$this->eventOrganiserInvitations->add($eventOrganiserInvitation);
$eventOrganiserInvitation->setEvent($this);
}
Expand All @@ -660,52 +659,52 @@ public function removeEventOrganiserInvitation(EventOrganiserInvitation $eventOr

public function hasRequestedToAttend(User $user): bool
{
return $this->getEventRequests()->exists(fn(int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
return $this->getEventRequests()->exists(fn (int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
}

public function hasBeenInvited(User $user): bool
{
return $this->getEventInvitations()->exists(fn(int $key, EventInvitation $eventInvitation) => $eventInvitation->getTarget() === $user);
return $this->getEventInvitations()->exists(fn (int $key, EventInvitation $eventInvitation) => $eventInvitation->getTarget() === $user);
}

public function hasEmailBeenInvited(string $emailAddress): bool
{
return $this->getEventEmailInvitations()->exists(fn(int $key, EventEmailInvitation $eventEmailInvitation) => $eventEmailInvitation->getEmail()->getAddress() === $emailAddress);
return $this->getEventEmailInvitations()->exists(fn (int $key, EventEmailInvitation $eventEmailInvitation) => $eventEmailInvitation->getEmail()->getAddress() === $emailAddress);
}

public function getRequestToAttend(User $user): null|EventRequest
{
return $this->getEventRequests()->findFirst(fn(int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
return $this->getEventRequests()->findFirst(fn (int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
}

public function attendRequest(User $user): null|EventRequest
{
return $this->getEventRequests()->findFirst(fn(int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
return $this->getEventRequests()->findFirst(fn (int $key, EventRequest $eventRequest) => $eventRequest->getOwner() === $user);
}

public function getIsAttending(User $user): bool
{
return $this->getEventParticipants()->exists(fn(int $key, EventParticipant $eventParticipant) => $eventParticipant->getOwner() === $user);
return $this->getEventParticipants()->exists(fn (int $key, EventParticipant $eventParticipant) => $eventParticipant->getOwner() === $user);
}

public function hasRated(User $user): bool
{
return $this->getEventReviews()->exists(fn(int $key, EventReview $eventReview) => $eventReview->getOwner() === $user);
return $this->getEventReviews()->exists(fn (int $key, EventReview $eventReview) => $eventReview->getOwner() === $user);
}

public function getIsOrganiser(User $user): bool
{
return $this->getEventOrganisers()->exists(fn(int $key, EventOrganiser $eventOrganiser) => $eventOrganiser->getOwner() === $user);
return $this->getEventOrganisers()->exists(fn (int $key, EventOrganiser $eventOrganiser) => $eventOrganiser->getOwner() === $user);
}

public function isAlreadyInvitedOrganiser(User $user): bool
{
return $this->eventOrganiserInvitations->exists(fn(int $key, EventOrganiserInvitation $eventOrganiserInvitation) => $eventOrganiserInvitation->getOwner() instanceof User && $eventOrganiserInvitation->getOwner() === $user);
return $this->eventOrganiserInvitations->exists(fn (int $key, EventOrganiserInvitation $eventOrganiserInvitation) => $eventOrganiserInvitation->getOwner() instanceof User && $eventOrganiserInvitation->getOwner() === $user);
}

public function isEmailAlreadyInvitedOrganiser(string $emailAddress): bool
{
return $this->eventOrganiserInvitations->exists(fn(int $key, EventOrganiserInvitation $eventOrganiserInvitation) => $eventOrganiserInvitation->getOwner()->getEmail()->getAddress() === $emailAddress);
return $this->eventOrganiserInvitations->exists(fn (int $key, EventOrganiserInvitation $eventOrganiserInvitation) => $eventOrganiserInvitation->getOwner()->getEmail()->getAddress() === $emailAddress);
}

/**
Expand All @@ -718,7 +717,7 @@ public function getEventReviews(): Collection

public function addEventReview(EventReview $eventReview): static
{
if (!$this->eventReviews->contains($eventReview)) {
if (! $this->eventReviews->contains($eventReview)) {
$this->eventReviews->add($eventReview);
$eventReview->setEvent($this);
}
Expand Down Expand Up @@ -748,7 +747,7 @@ public function getEventMoments(): Collection

public function addEventMoment(EventMoment $eventChangeLog): static
{
if (!$this->eventMoments->contains($eventChangeLog)) {
if (! $this->eventMoments->contains($eventChangeLog)) {
$this->eventMoments->add($eventChangeLog);
$eventChangeLog->setEvent($this);
}
Expand Down Expand Up @@ -778,7 +777,7 @@ public function getTicketOptions(): Collection

public function addTicketOption(EventTicketOption $ticketOption): static
{
if (!$this->ticketOptions->contains($ticketOption)) {
if (! $this->ticketOptions->contains($ticketOption)) {
$this->ticketOptions->add($ticketOption);
$ticketOption->setEvent($this);
}
Expand Down
Loading

0 comments on commit 5231461

Please sign in to comment.