denormalize()   F
last analyzed

Complexity

Conditions 11
Paths 513

Size

Total Lines 35
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 35
rs 3.8263
c 0
b 0
f 0
cc 11
nc 513
nop 4

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file has been auto generated by Jane,
7
 *
8
 * Do no edit it directly.
9
 */
10
11
namespace Montross50\NetsparkerCloud\SDK\Normalizer;
12
13
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
14
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
15
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
16
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
17
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
18
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
19
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
20
21
class UpdateScanNotificationApiModelNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
22
{
23
    use DenormalizerAwareTrait;
24
    use NormalizerAwareTrait;
25
26
    public function supportsDenormalization($data, $type, $format = null)
27
    {
28
        return $type === 'Montross50\\NetsparkerCloud\\SDK\\Model\\UpdateScanNotificationApiModel';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\UpdateScanNotificationApiModel;
34
    }
35
36
    public function denormalize($data, $class, $format = null, array $context = [])
37
    {
38
        if (!is_object($data)) {
39
            throw new InvalidArgumentException();
40
        }
41
        $object = new \Montross50\NetsparkerCloud\SDK\Model\UpdateScanNotificationApiModel();
42
        if (property_exists($data, 'Id')) {
43
            $object->setId($data->{'Id'});
44
        }
45
        if (property_exists($data, 'Recipients')) {
46
            $object->setRecipients($this->denormalizer->denormalize($data->{'Recipients'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\NewScanNotificationRecipientApiModel', 'json', $context));
47
        }
48
        if (property_exists($data, 'WebsiteGroupName')) {
49
            $object->setWebsiteGroupName($data->{'WebsiteGroupName'});
50
        }
51
        if (property_exists($data, 'WebsiteRootUrl')) {
52
            $object->setWebsiteRootUrl($data->{'WebsiteRootUrl'});
53
        }
54
        if (property_exists($data, 'Disabled')) {
55
            $object->setDisabled($data->{'Disabled'});
56
        }
57
        if (property_exists($data, 'Event')) {
58
            $object->setEvent($data->{'Event'});
59
        }
60
        if (property_exists($data, 'LowestSeverity')) {
61
            $object->setLowestSeverity($data->{'LowestSeverity'});
62
        }
63
        if (property_exists($data, 'Name')) {
64
            $object->setName($data->{'Name'});
65
        }
66
        if (property_exists($data, 'Scope')) {
67
            $object->setScope($data->{'Scope'});
68
        }
69
70
        return $object;
71
    }
72
73
    public function normalize($object, $format = null, array $context = [])
74
    {
75
        $data = new \stdClass();
76
        if (null !== $object->getId()) {
77
            $data->{'Id'} = $object->getId();
78
        }
79
        if (null !== $object->getRecipients()) {
80
            $data->{'Recipients'} = $this->normalizer->normalize($object->getRecipients(), 'json', $context);
81
        }
82
        if (null !== $object->getWebsiteGroupName()) {
83
            $data->{'WebsiteGroupName'} = $object->getWebsiteGroupName();
84
        }
85
        if (null !== $object->getWebsiteRootUrl()) {
86
            $data->{'WebsiteRootUrl'} = $object->getWebsiteRootUrl();
87
        }
88
        if (null !== $object->getDisabled()) {
89
            $data->{'Disabled'} = $object->getDisabled();
90
        }
91
        if (null !== $object->getEvent()) {
92
            $data->{'Event'} = $object->getEvent();
93
        }
94
        if (null !== $object->getLowestSeverity()) {
95
            $data->{'LowestSeverity'} = $object->getLowestSeverity();
96
        }
97
        if (null !== $object->getName()) {
98
            $data->{'Name'} = $object->getName();
99
        }
100
        if (null !== $object->getScope()) {
101
            $data->{'Scope'} = $object->getScope();
102
        }
103
104
        return $data;
105
    }
106
}
107