Passed
Push — master ( 7f3859...443fcf )
by Nikolay
01:06 queued 11s
created

LegacyObjectNormalizerWrapper::normalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 10
cc 1
nc 1
nop 3
crap 1.0156
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 94
    public function __construct(AbstractNormalizer $normalizer)
20
    {
21 94
        $this->normalizer = $normalizer;
22 94
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 94
    public function normalize($object, $format = null, array $context = [])
28
    {
29 94
        $data = $this->normalizer->normalize($object, $format, $context);
30
31
        return \array_filter($data, static function ($value) {
32 86
            return null !== $value;
33 94
        });
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 94
    public function supportsNormalization($data, $format = null)
40
    {
41 94
        return $this->normalizer->supportsNormalization($data, $format);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 94
    public function setSerializer(SerializerInterface $serializer)
48
    {
49 94
        $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 94
    }
51
}
52