DeserializableCommandDenormalizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A denormalize() 0 4 1
A supportsDenormalization() 0 5 1
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