Completed
Pull Request — master (#18)
by Antonio
37:55 queued 33:50
created

AttributeOptionNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 9 1
A supportsNormalization() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Flagbit\Bundle\TableAttributeBundle\Normalizer;
4
5
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
6
7
class AttributeOptionNormalizer implements NormalizerInterface
8
{
9
    /** @var NormalizerInterface */
10
    private $baseNormalizer;
11
12
    /**
13
     * StructuredAttributeOptionNormalizer constructor.
14
     *
15
     * @param NormalizerInterface $baseNormalizer
16
     */
17
    public function __construct(NormalizerInterface $baseNormalizer)
18
    {
19
        $this->baseNormalizer = $baseNormalizer;
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function normalize($object, $format = null, array $context = [])
26
    {
27
        $normalizedValues = $this->baseNormalizer->normalize($object, $format, $context);
28
29
        $normalizedValues['type'] = $object->getType();
30
        $normalizedValues['type_config'] = $object->getTypeConfig();
31
        $normalizedValues['constraints'] = $object->getConstraints();
32
33
        return $normalizedValues;
34
    }
35
36
    /**
37
     * @param mixed $data
38
     * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
39
     * @return bool
40
     */
41
    public function supportsNormalization($data, $format = null)
42
    {
43
        return $this->baseNormalizer->supportsNormalization($data, $format);
44
    }
45
}
46