Completed
Push — 6.13 ( fb0043...d86c76 )
by André
18:03
created

SerializerStub   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 4 1
A deserialize() 0 4 1
A normalize() 0 19 4
A supportsNormalization() 0 4 1
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
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs;
10
11
use eZ\Publish\API\Repository\Exceptions\NotImplementedException;
12
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
13
use Symfony\Component\Serializer\SerializerInterface;
14
15
final class SerializerStub implements SerializerInterface, NormalizerInterface
16
{
17
    public function serialize($data, $format, array $context = [])
18
    {
19
        throw new NotImplementedException(__METHOD__);
20
    }
21
22
    public function deserialize($data, $type, $format, array $context = [])
23
    {
24
        throw new NotImplementedException(__METHOD__);
25
    }
26
27
    public function normalize($object, $format = null, array $context = [])
28
    {
29
        if (is_array($object)) {
30
            $result = [];
31
            foreach ($object as $key => $value) {
32
                $result[$key] = $this->normalize($value, $format, $context);
33
            }
34
35
            return $result;
36
        }
37
38
        if ($object instanceof MatcherStub) {
39
            return [
40
                'data' => $object->getData(),
41
            ];
42
        }
43
44
        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...
45
    }
46
47
    public function supportsNormalization($data, $format = null)
48
    {
49
        return true;
50
    }
51
}
52