Completed
Pull Request — master (#18)
by
unknown
15:15 queued 05:39
created

AttributeOptionNormalizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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