Passed
Push — feature/VSVGVQ-20 ( 97a728...3275f0 )
by steven
02:56
created

supportsDenormalization()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Company\Serializers;
4
5
use Ramsey\Uuid\Uuid;
6
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
7
use VSV\GVQ_API\Common\ValueObjects\Language;
8
use VSV\GVQ_API\Company\Models\TranslatedAlias;
9
use VSV\GVQ_API\Company\ValueObjects\Alias;
10
11
class TranslatedAliasDenormalizer implements DenormalizerInterface
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function denormalize($data, $class, $format = null, array $context = array()): TranslatedAlias
17
    {
18
        return new TranslatedAlias(
19
            Uuid::fromString($data['id']),
20
            new Language($data['language']),
21
            new Alias($data['alias'])
22
        );
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function supportsDenormalization($data, $type, $format = null): bool
29
    {
30
        return ($type === TranslatedAlias::class) && ($format === 'json');
31
    }
32
}
33