Completed
Push — master ( 99fd04...6a3a72 )
by Jakub
02:38
created

DeserializableCommandDenormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A denormalize() 0 4 1
A supportsDenormalization() 0 4 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
     */
22
    public function supportsDenormalization($data, $type, $format = null): bool
23
    {
24
        return is_subclass_of($type, DeserializableCommandInterface::class);
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Eps\Req2CmdBundle\Comma...CommandInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
25
    }
26
}
27