Passed
Pull Request — master (#18)
by
unknown
09:25 queued 04:40
created

AttributeOptionNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 3
eloc 9
c 3
b 0
f 1
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsNormalization() 0 3 1
A __construct() 0 3 1
A normalize() 0 9 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
    public function __construct(NormalizerInterface $baseNormalizer)
13
    {
14
        $this->baseNormalizer = $baseNormalizer;
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function normalize($object, $format = null, array $context = [])
21
    {
22
        $normalizedValues = $this->baseNormalizer->normalize($object, $format, $context);
23
24
        $normalizedValues['type'] = $object->getType();
25
        $normalizedValues['type_config'] = $object->getTypeConfig();
26
        $normalizedValues['constraints'] = $object->getConstraints();
27
28
        return $normalizedValues;
29
    }
30
31
    /**
32
     * @param mixed $data
33
     * @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...
34
     * @return bool
35
     */
36
    public function supportsNormalization($data, $format = null)
37
    {
38
        return $this->baseNormalizer->supportsNormalization($data, $format);
39
    }
40
}
41