Completed
Pull Request — master (#348)
by
unknown
09:42 queued 08:20
created

CustomReferencedNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ONGR\ElasticsearchDSL\Serializer\Normalizer;
15
16
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
17
18
class CustomReferencedNormalizer extends CustomNormalizer
19
{
20
    private array $references = [];
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
21
22
    public function normalize($object, $format = null, array $context = []): mixed
23
    {
24
        $object->setReferences($this->references);
25
        $data = parent::normalize($object, $format, $context);
26
        $this->references = array_merge($this->references, $object->getReferences());
27
28
        return $data;
29
    }
30
31
    public function supportsNormalization(mixed $data, $format = null): bool
32
    {
33
        return $data instanceof AbstractNormalizable;
34
    }
35
}
36