mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-02-01 05:57:16 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,17 +17,13 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function is_array;
|
||||
|
||||
class DoctrineExistingEntityNormalizer implements DenormalizerInterface
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly ClassMetadataFactoryInterface $serializerMetadataFactory) {}
|
||||
|
||||
public function denormalize($data, $type, $format = null, array $context = [])
|
||||
{
|
||||
if (array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
|
||||
if (\array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
|
||||
return $context[AbstractNormalizer::OBJECT_TO_POPULATE];
|
||||
}
|
||||
|
||||
@@ -37,11 +33,11 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
|
||||
|
||||
public function supportsDenormalization($data, $type, $format = null)
|
||||
{
|
||||
if (false === is_array($data)) {
|
||||
if (false === \is_array($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === array_key_exists('id', $data)) {
|
||||
if (false === \array_key_exists('id', $data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,13 +56,13 @@ class DoctrineExistingEntityNormalizer implements DenormalizerInterface
|
||||
// check that only 2 keys
|
||||
// that the second key is property
|
||||
// and that the type match the class for given type property
|
||||
return count($data) === 2
|
||||
&& array_key_exists($typeProperty, $data)
|
||||
return 2 === \count($data)
|
||||
&& \array_key_exists($typeProperty, $data)
|
||||
&& $classDiscriminator->getClassForType($data[$typeProperty]) === $type;
|
||||
}
|
||||
}
|
||||
|
||||
// we do not have any class discriminator. Check that the id is the only one key
|
||||
return count($data) === 1;
|
||||
return 1 === \count($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user