From fc61dfdf3a928b56ed22c6b03894898f866ecdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 2 Jun 2025 15:51:11 +0200 Subject: [PATCH] Fix CS and add more comments within ticket bundle --- .../GeographicalUnitStatAggregator.php | 2 +- .../PersonACLAwareRepositoryInterface.php | 2 +- .../src/Action/Ticket/AddAddresseeCommand.php | 2 +- .../src/Action/Ticket/SetAddresseesCommand.php | 2 +- .../src/Action/Ticket/SetPersonsCommand.php | 2 +- .../src/Controller/EditTicketController.php | 4 ++-- .../src/Entity/AddresseeHistory.php | 7 +++++++ .../ChillTicketBundle/src/Entity/Comment.php | 5 +++++ .../ChillTicketBundle/src/Entity/InputHistory.php | 5 +++++ .../ChillTicketBundle/src/Entity/MotiveHistory.php | 8 +++++++- .../ChillTicketBundle/src/Entity/PersonHistory.php | 4 ++++ src/Bundle/ChillTicketBundle/src/Entity/Ticket.php | 14 ++++++++++++++ .../SetAddresseesCommandDenormalizer.php | 2 +- 13 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index ffa5501dd..caf8808cf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -31,7 +31,7 @@ final readonly class GeographicalUnitStatAggregator implements AggregatorInterfa public function __construct( private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, - private RollingDateConverterInterface $rollingDateConverter + private RollingDateConverterInterface $rollingDateConverter, ) {} public function addRole(): ?string diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php index d63c25bd8..aeaefecd4 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepositoryInterface.php @@ -68,6 +68,6 @@ interface PersonACLAwareRepositoryInterface public function findByPhone( PhoneNumber $phoneNumber, int $start = 0, - int $limit = 20 + int $limit = 20, ): array; } diff --git a/src/Bundle/ChillTicketBundle/src/Action/Ticket/AddAddresseeCommand.php b/src/Bundle/ChillTicketBundle/src/Action/Ticket/AddAddresseeCommand.php index d7f9c545f..0e16876d8 100644 --- a/src/Bundle/ChillTicketBundle/src/Action/Ticket/AddAddresseeCommand.php +++ b/src/Bundle/ChillTicketBundle/src/Action/Ticket/AddAddresseeCommand.php @@ -24,6 +24,6 @@ final readonly class AddAddresseeCommand { public function __construct( #[Groups(['read'])] - public User|UserGroup $addressee + public User|UserGroup $addressee, ) {} } diff --git a/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetAddresseesCommand.php b/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetAddresseesCommand.php index e0d474d11..f258731f7 100644 --- a/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetAddresseesCommand.php +++ b/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetAddresseesCommand.php @@ -27,7 +27,7 @@ final readonly class SetAddresseesCommand #[UserGroupDoNotExclude] #[GreaterThan(0)] #[Groups(['read'])] - public array $addressees + public array $addressees, ) {} public static function fromAddAddresseeCommand(AddAddresseeCommand $command, Ticket $ticket): self diff --git a/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetPersonsCommand.php b/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetPersonsCommand.php index 6bd47a567..69ba61977 100644 --- a/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetPersonsCommand.php +++ b/src/Bundle/ChillTicketBundle/src/Action/Ticket/SetPersonsCommand.php @@ -23,6 +23,6 @@ class SetPersonsCommand */ #[GreaterThan(0)] #[Groups(['read'])] - public array $persons + public array $persons, ) {} } diff --git a/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php b/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php index 0e8fcd7e5..fcff2aa56 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php @@ -19,12 +19,12 @@ use Twig\Environment; class EditTicketController { public function __construct( - private Environment $templating + private Environment $templating, ) {} #[Route('/{_locale}/ticket/ticket/{id}/edit', name: 'chill_ticket_ticket_edit')] public function __invoke( - Ticket $ticket + Ticket $ticket, ): Response { return new Response( $this->templating->render( diff --git a/src/Bundle/ChillTicketBundle/src/Entity/AddresseeHistory.php b/src/Bundle/ChillTicketBundle/src/Entity/AddresseeHistory.php index 2717df2a5..ee1d87dee 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/AddresseeHistory.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/AddresseeHistory.php @@ -20,6 +20,13 @@ use Chill\MainBundle\Entity\UserGroup; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; +/** + * Represents the history entity for addressees in the context of a ticketing system. + * + * Tracks information about addressees for a specific ticket, including user or group associability, + * timestamps marking the start and end of the association, and the removal of assignments. + * Implements mechanisms for tracking entity creation and updates. + */ #[ORM\Entity()] #[ORM\Table(name: 'addressee_history', schema: 'chill_ticket')] #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_addressee_history' => AddresseeHistory::class])] diff --git a/src/Bundle/ChillTicketBundle/src/Entity/Comment.php b/src/Bundle/ChillTicketBundle/src/Entity/Comment.php index 8e11ff489..8da2342ee 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/Comment.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/Comment.php @@ -19,6 +19,11 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping\JoinColumn; use Symfony\Component\Serializer\Annotation as Serializer; +/** + * Represents a comment entity within the application. + * + * This entity is associated with a specific ticket and includes creation and update tracking. + */ #[ORM\Entity()] #[ORM\Table(name: 'comment', schema: 'chill_ticket')] #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_comment' => Comment::class])] diff --git a/src/Bundle/ChillTicketBundle/src/Entity/InputHistory.php b/src/Bundle/ChillTicketBundle/src/Entity/InputHistory.php index 2b25ae6ac..a43bf7a1f 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/InputHistory.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/InputHistory.php @@ -16,6 +16,11 @@ use Chill\PersonBundle\Entity\Person; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\Mapping as ORM; +/** + * History of input for a single ticket. + * + * An input is someone who triggered the opening of the ticket. Typically, it's the "caller" of a call. + */ #[ORM\Entity()] #[ORM\Table(name: 'input_history', schema: 'chill_ticket')] class InputHistory diff --git a/src/Bundle/ChillTicketBundle/src/Entity/MotiveHistory.php b/src/Bundle/ChillTicketBundle/src/Entity/MotiveHistory.php index 1922459e8..e2902aae3 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/MotiveHistory.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/MotiveHistory.php @@ -16,6 +16,12 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; +/** + * Represents the history of a motive associated with a ticket. + * + * This entity is used to track the changes in a ticket's motive over time. + * Implements the TrackCreationInterface for tracking entity lifecycle creation. + */ #[ORM\Entity] #[ORM\Table(name: 'motives_history', schema: 'chill_ticket')] #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_motive_history' => MotiveHistory::class])] @@ -43,7 +49,7 @@ class MotiveHistory implements TrackCreationInterface private Ticket $ticket, #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)] #[Serializer\Groups(['read'])] - private \DateTimeImmutable $startDate = new \DateTimeImmutable('now') + private \DateTimeImmutable $startDate = new \DateTimeImmutable('now'), ) { $ticket->addMotiveHistory($this); } diff --git a/src/Bundle/ChillTicketBundle/src/Entity/PersonHistory.php b/src/Bundle/ChillTicketBundle/src/Entity/PersonHistory.php index 1fce78fa1..042b7395b 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/PersonHistory.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/PersonHistory.php @@ -18,6 +18,10 @@ use Chill\PersonBundle\Entity\Person; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; +/** + * Represents a history entity associated with a person and a ticket. + * Tracks the start date, end date, and the user who removed the entry (if applicable). + */ #[ORM\Entity] #[ORM\Table(name: 'person_history', schema: 'chill_ticket')] #[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['ticket_person_history' => PersonHistory::class])] diff --git a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php index 04cfe828b..84b07eb17 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php @@ -24,6 +24,20 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ReadableCollection; use Doctrine\ORM\Mapping as ORM; +/** + * This entity represents a `Ticket` in the application and provides functionality for managing its associated + * histories, comments, and current data such as addressees, inputs, and motives. + * + * Most of the associated data are handle through "histories", with a many-to-one relationship (a ticket may have multiple) + * history. The history contains the associated data (see below) and start dates and end dates. + * + * There are histories for: + * + * - association between the ticket and persons: @see{PersonHistory}; + * - association between the ticket and motive: @see{MotiveHistory}; + * - association between the ticket and addresses: @see{AddresseeHistory}; + * - association between the ticket and input: @see{InputHistory}; + */ #[ORM\Entity] #[ORM\Table(name: 'ticket', schema: 'chill_ticket')] class Ticket implements TrackCreationInterface, TrackUpdateInterface diff --git a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php index d97ca5d92..86a843cd5 100644 --- a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php +++ b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php @@ -42,7 +42,7 @@ final class SetAddresseesCommandDenormalizer implements DenormalizerInterface, D $addresses[] = match ($address['type'] ?? '') { 'user_group' => $this->denormalizer->denormalize($address, UserGroup::class, $format, $context), 'user' => $this->denormalizer->denormalize($address, User::class, $format, $context), - default => throw new UnexpectedValueException('the type is not set or not supported') + default => throw new UnexpectedValueException('the type is not set or not supported'), }; }