CategoryDenormalizer::supportsDenormalization()   A
last analyzed

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\Question\Serializers;
4
5
use Ramsey\Uuid\Uuid;
6
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
7
use VSV\GVQ_API\Question\Models\Category;
8
use VSV\GVQ_API\Common\ValueObjects\NotEmptyString;
9
10
class CategoryDenormalizer implements DenormalizerInterface
11
{
12
    /**
13
     * @inheritdoc
14
     */
15
    public function denormalize($data, $class, $format = null, array $context = []): Category
16
    {
17
        return new Category(
18
            Uuid::fromString($data['id']),
19
            new NotEmptyString($data['name'])
20
        );
21
    }
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function supportsDenormalization($data, $type, $format = null): bool
27
    {
28
        return ($type === Category::class) && ($format === 'json');
29
    }
30
}
31