Passed
Pull Request — master (#32)
by
unknown
18:56
created

OrderStatusLanguageModelCollectionNormalizer   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 11

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsDenormalization() 0 3 1
A normalize() 0 11 3
A denormalize() 0 14 5
A supportsNormalization() 0 3 2
1
<?php
2
3
namespace Starweb\Api\Generated\Normalizer;
4
5
use Jane\JsonSchemaRuntime\Reference;
6
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
7
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
8
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
9
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
10
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
11
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
12
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
13
class OrderStatusLanguageModelCollectionNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
14
{
15
    use DenormalizerAwareTrait;
16
    use NormalizerAwareTrait;
17
    public function supportsDenormalization($data, $type, $format = null)
18
    {
19
        return $type === 'Starweb\\Api\\Generated\\Model\\OrderStatusLanguageModelCollection';
20
    }
21
    public function supportsNormalization($data, $format = null)
22
    {
23
        return is_object($data) && get_class($data) === 'Starweb\\Api\\Generated\\Model\\OrderStatusLanguageModelCollection';
24
    }
25
    public function denormalize($data, $class, $format = null, array $context = array())
26
    {
27
        if (!is_object($data)) {
28
            return null;
29
        }
30
        $object = new \Starweb\Api\Generated\Model\OrderStatusLanguageModelCollection();
31
        if (property_exists($data, 'data') && $data->{'data'} !== null) {
32
            $values = array();
33
            foreach ($data->{'data'} as $value) {
34
                $values[] = $this->denormalizer->denormalize($value, 'Starweb\\Api\\Generated\\Model\\OrderStatusLanguageModel', 'json', $context);
35
            }
36
            $object->setData($values);
37
        }
38
        return $object;
39
    }
40
    public function normalize($object, $format = null, array $context = array())
41
    {
42
        $data = new \stdClass();
43
        if (null !== $object->getData()) {
44
            $values = array();
45
            foreach ($object->getData() as $value) {
46
                $values[] = $this->normalizer->normalize($value, 'json', $context);
47
            }
48
            $data->{'data'} = $values;
49
        }
50
        return $data;
51
    }
52
}