Completed
Push — EZP-31681 ( 54659b...e049ce )
by
unknown
18:38 queued 10s
created

SerializerStub::normalize()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 3
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs;
8
9
use eZ\Publish\API\Repository\Exceptions\NotImplementedException;
10
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
11
use Symfony\Component\Serializer\SerializerInterface;
12
13
final class SerializerStub implements SerializerInterface, NormalizerInterface
14
{
15
    public function serialize($data, $format, array $context = [])
16
    {
17
        throw new NotImplementedException(__METHOD__);
18
    }
19
20
    public function deserialize($data, $type, $format, array $context = [])
21
    {
22
        throw new NotImplementedException(__METHOD__);
23
    }
24
25
    public function normalize($object, $format = null, array $context = [])
26
    {
27
        if (is_array($object)) {
28
            $result = [];
29
            foreach ($object as $key => $value) {
30
                $result[$key] = $this->normalize($value, $format, $context);
31
            }
32
33
            return $result;
34
        }
35
36
        if ($object instanceof MatcherStub) {
37
            return [
38
                'data' => $object->getData(),
39
            ];
40
        }
41
42
        return $object;
0 ignored issues
show
Bug Compatibility introduced by
The expression return $object; of type object|integer|double|string|null|boolean is incompatible with the return type declared by the interface Symfony\Component\Serial...zerInterface::normalize of type array|string|integer|double|boolean|null as it can also be of type object which is not included in this return type.
Loading history...
43
    }
44
45
    public function supportsNormalization($data, $format = null)
46
    {
47
        return true;
48
    }
49
}
50