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

AttributeOptionNormalizer::normalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 9
rs 10
c 0
b 0
f 0
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