Completed
Push — master ( 588078...30ae0c )
by Nikolay
04:51 queued 02:15
created

supportsDenormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Greenplugin\TelegramBot\Normalizer;
6
7
use Greenplugin\TelegramBot\Type\PhotoSizeType;
8
use Greenplugin\TelegramBot\Type\UserProfilePhotosType;
9
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
10
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
11
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
12
use Symfony\Component\Serializer\Serializer;
13
14
class UserProfilePhotosNormalizer implements DenormalizerInterface
15
{
16
    private $objectNormalizer;
17
    private $arrayDenormalizer;
18
19 4
    public function __construct(NormalizerInterface $objectNormalizer, ArrayDenormalizer $arrayDenormalizer)
20
    {
21 4
        $this->objectNormalizer = $objectNormalizer;
22 4
        $this->arrayDenormalizer = $arrayDenormalizer;
23 4
    }
24
25 1
    public function denormalize($data, $class, $format = null, array $context = [])
26
    {
27 1
        $serializer = new Serializer([$this->objectNormalizer, $this->arrayDenormalizer]);
28 1
        $data['photos'] = $serializer->denormalize($data['photos'], PhotoSizeType::class . '[][]');
29
30 1
        return $serializer->denormalize($data, UserProfilePhotosType::class);
31
    }
32
33 4
    public function supportsDenormalization($data, $type, $format = null)
34
    {
35 4
        return UserProfilePhotosType::class === $type;
36
    }
37
}
38