Make methods private in ExportDataNormalizerTrait

Changed the visibility of several methods from public to private to improve encapsulation and restrict access to internal logic. This enhances code maintainability and prevents unintended use outside the intended scope.
This commit is contained in:
Julien Fastré 2025-04-25 11:31:31 +02:00
parent 8521672660
commit b414b27ba9
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -30,7 +30,7 @@ trait ExportDataNormalizerTrait
* an array of their identifiers is returned. If a single entity is provided, its identifier * an array of their identifiers is returned. If a single entity is provided, its identifier
* is returned. If null, returns an empty value. * is returned. If null, returns an empty value.
*/ */
public function normalizeDoctrineEntity(object|array|null $entity): array|int|string private function normalizeDoctrineEntity(object|array|null $entity): array|int|string
{ {
if (is_array($entity)) { if (is_array($entity)) {
return array_values(array_filter(array_map(static fn (object $entity) => $entity->getId(), $entity), fn ($value) => null !== $value)); return array_values(array_filter(array_map(static fn (object $entity) => $entity->getId(), $entity), fn ($value) => null !== $value));
@ -52,7 +52,7 @@ trait ExportDataNormalizerTrait
* *
* @throws \UnexpectedValueException when the entity with the given ID does not exist * @throws \UnexpectedValueException when the entity with the given ID does not exist
*/ */
public function denormalizeDoctrineEntity(array|int|string $id, ObjectRepository $repository): object|array private function denormalizeDoctrineEntity(array|int|string $id, ObjectRepository $repository): object|array
{ {
if (is_array($id)) { if (is_array($id)) {
return $repository->findBy(['id' => $id]); return $repository->findBy(['id' => $id]);
@ -145,7 +145,7 @@ trait ExportDataNormalizerTrait
* *
* @return string a formatted string containing the type and formatted date * @return string a formatted string containing the type and formatted date
*/ */
public function normalizeDate(\DateTimeImmutable|\DateTime $date): string private function normalizeDate(\DateTimeImmutable|\DateTime $date): string
{ {
return sprintf( return sprintf(
'%s,%s', '%s,%s',
@ -166,7 +166,7 @@ trait ExportDataNormalizerTrait
* *
* @throws \UnexpectedValueException if the kind selector or date format is invalid * @throws \UnexpectedValueException if the kind selector or date format is invalid
*/ */
public function denormalizeDate(string $date): \DateTimeImmutable|\DateTime private function denormalizeDate(string $date): \DateTimeImmutable|\DateTime
{ {
$format = 'd-m-Y-H:i:s.u e'; $format = 'd-m-Y-H:i:s.u e';