DeserializableCommandDenormalizer::denormalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Eps\Req2CmdBundle\Serializer;
5
6
use Eps\Req2CmdBundle\Command\DeserializableCommandInterface;
7
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
8
9
class DeserializableCommandDenormalizer implements DenormalizerInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function denormalize($data, $class, $format = null, array $context = [])
15
    {
16
        return call_user_func($class . '::fromArray', $data);
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     * @throws \ReflectionException
22
     */
23
    public function supportsDenormalization($data, $type, $format = null): bool
24
    {
25
        $reflClass = new \ReflectionClass($type);
26
        return $reflClass->implementsInterface(DeserializableCommandInterface::class);
27
    }
28
}
29