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

LegacyObjectNormalizerWrapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 17
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsNormalization() 0 3 1
A setSerializer() 0 3 1
A normalize() 0 6 1
A __construct() 0 3 1
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