Passed
Push — master ( 443fcf...179750 )
by Nikolay
02:29
created

LegacyObjectNormalizerWrapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TgBotApi\BotApiBase\Normalizer;
6
7
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
8
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
9
use Symfony\Component\Serializer\SerializerAwareInterface;
10
use Symfony\Component\Serializer\SerializerInterface;
11
12
class LegacyObjectNormalizerWrapper implements NormalizerInterface, SerializerAwareInterface
13
{
14
    /**
15
     * @var NormalizerInterface
16
     */
17
    private $normalizer;
18
19
    public function __construct(AbstractNormalizer $normalizer)
20
    {
21
        $this->normalizer = $normalizer;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function normalize($object, $format = null, array $context = [])
28
    {
29
        $data = $this->normalizer->normalize($object, $format, $context);
30
31
        return \array_filter($data, static function ($value) {
32
            return null !== $value;
33
        });
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function supportsNormalization($data, $format = null)
40
    {
41
        return $this->normalizer->supportsNormalization($data, $format);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function setSerializer(SerializerInterface $serializer)
48
    {
49
        $this->normalizer->setSerializer($serializer);
0 ignored issues
show
Bug introduced by
The method setSerializer() does not exist on Symfony\Component\Serial...zer\NormalizerInterface. It seems like you code against a sub-type of Symfony\Component\Serial...zer\NormalizerInterface such as TgBotApi\BotApiBase\Norm...ObjectNormalizerWrapper or Symfony\Component\Serial...alizer\CustomNormalizer or Symfony\Component\Serial...izer\AbstractNormalizer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        $this->normalizer->/** @scrutinizer ignore-call */ 
50
                           setSerializer($serializer);
Loading history...
50
    }
51
}
52