mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -20,8 +20,6 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
@@ -31,10 +29,6 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* Serialize a Person entity.
|
||||
@@ -60,13 +54,13 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
{
|
||||
$person = $this->extractObjectToPopulate($type, $context);
|
||||
|
||||
if (array_key_exists('id', $data) && null === $person) {
|
||||
if (\array_key_exists('id', $data) && null === $person) {
|
||||
$person = $this->repository->find($data['id']);
|
||||
|
||||
if (null === $person) {
|
||||
throw new UnexpectedValueException("The person with id \"{$data['id']}\" does " .
|
||||
'not exists');
|
||||
throw new UnexpectedValueException("The person with id \"{$data['id']}\" does ".'not exists');
|
||||
}
|
||||
|
||||
// currently, not allowed to update a person through api
|
||||
// if instantiated with id
|
||||
return $person;
|
||||
@@ -92,7 +86,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
|
||||
$fields = array_filter(
|
||||
$fields,
|
||||
static fn (string $field): bool => array_key_exists($field, $data)
|
||||
static fn (string $field): bool => \array_key_exists($field, $data)
|
||||
);
|
||||
|
||||
foreach ($fields as $item) {
|
||||
@@ -123,14 +117,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
break;
|
||||
|
||||
case 'birthdate':
|
||||
$object = $this->denormalizer->denormalize($data[$item], DateTime::class, $format, $context);
|
||||
$object = $this->denormalizer->denormalize($data[$item], \DateTime::class, $format, $context);
|
||||
|
||||
$person->setBirthdate($object);
|
||||
|
||||
break;
|
||||
|
||||
case 'deathdate':
|
||||
$object = $this->denormalizer->denormalize($data[$item], DateTimeImmutable::class, $format, $context);
|
||||
$object = $this->denormalizer->denormalize($data[$item], \DateTimeImmutable::class, $format, $context);
|
||||
|
||||
$person->setDeathdate($object);
|
||||
|
||||
@@ -178,14 +172,14 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @param Person $person
|
||||
* @param string|null $format
|
||||
*/
|
||||
public function normalize($person, $format = null, array $context = [])
|
||||
{
|
||||
$groups = $context[AbstractNormalizer::GROUPS] ?? [];
|
||||
|
||||
if (is_string($groups)) {
|
||||
if (\is_string($groups)) {
|
||||
$groups = [$groups];
|
||||
}
|
||||
$household = $person->getCurrentHousehold();
|
||||
@@ -209,7 +203,7 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
'civility' => $this->normalizer->normalize($person->getCivility(), $format, $context),
|
||||
];
|
||||
|
||||
if (in_array('minimal', $groups, true) && 1 === count($groups)) {
|
||||
if (\in_array('minimal', $groups, true) && 1 === \count($groups)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user