CustomReferencedNormalizer   A
last analyzed

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 8 1
A supportsNormalization() 0 4 1
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
namespace ONGR\ElasticsearchDSL\Serializer\Normalizer;
13
14
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
15
16
/**
17
 * Normalizer used with referenced normalized objects.
18
 */
19
class CustomReferencedNormalizer extends CustomNormalizer
20
{
21
    /**
22
     * @var array
23
     */
24
    private $references = [];
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function normalize($object, $format = null, array $context = [])
30
    {
31
        $object->setReferences($this->references);
32
        $data = parent::normalize($object, $format, $context);
33
        $this->references = array_merge($this->references, $object->getReferences());
34
35
        return $data;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function supportsNormalization($data, $format = null)
42
    {
43
        return $data instanceof AbstractNormalizable;
44
    }
45
}
46