AccountLicenseApiModelNormalizer::normalize()   F
last analyzed

Complexity

Conditions 12
Paths 1024

Size

Total Lines 39
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 39
rs 2.8
c 0
b 0
f 0
cc 12
nc 1024
nop 3

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 AccountLicenseApiModelNormalizer 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\\AccountLicenseApiModel';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\AccountLicenseApiModel;
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\AccountLicenseApiModel();
42
        if (property_exists($data, 'SubscriptionMaximumSiteLimit')) {
43
            $object->setSubscriptionMaximumSiteLimit($data->{'SubscriptionMaximumSiteLimit'});
44
        }
45
        if (property_exists($data, 'SubscriptionSiteCount')) {
46
            $object->setSubscriptionSiteCount($data->{'SubscriptionSiteCount'});
47
        }
48
        if (property_exists($data, 'SubscriptionEndDate')) {
49
            $object->setSubscriptionEndDate($data->{'SubscriptionEndDate'});
50
        }
51
        if (property_exists($data, 'SubscriptionStartDate')) {
52
            $object->setSubscriptionStartDate($data->{'SubscriptionStartDate'});
53
        }
54
        if (property_exists($data, 'IsAccountWhitelisted')) {
55
            $object->setIsAccountWhitelisted($data->{'IsAccountWhitelisted'});
56
        }
57
        if (property_exists($data, 'UsedScanCreditCount')) {
58
            $object->setUsedScanCreditCount($data->{'UsedScanCreditCount'});
59
        }
60
        if (property_exists($data, 'ScanCreditCount')) {
61
            $object->setScanCreditCount($data->{'ScanCreditCount'});
62
        }
63
        if (property_exists($data, 'IsCreditScanEnabled')) {
64
            $object->setIsCreditScanEnabled($data->{'IsCreditScanEnabled'});
65
        }
66
        if (property_exists($data, 'IsSubscriptionEnabled')) {
67
            $object->setIsSubscriptionEnabled($data->{'IsSubscriptionEnabled'});
68
        }
69
        if (property_exists($data, 'PreVerifiedWebsites')) {
70
            $values = [];
71
            foreach ($data->{'PreVerifiedWebsites'} as $value) {
72
                $values[] = $value;
73
            }
74
            $object->setPreVerifiedWebsites($values);
75
        }
76
77
        return $object;
78
    }
79
80
    public function normalize($object, $format = null, array $context = [])
81
    {
82
        $data = new \stdClass();
83
        if (null !== $object->getSubscriptionMaximumSiteLimit()) {
84
            $data->{'SubscriptionMaximumSiteLimit'} = $object->getSubscriptionMaximumSiteLimit();
85
        }
86
        if (null !== $object->getSubscriptionSiteCount()) {
87
            $data->{'SubscriptionSiteCount'} = $object->getSubscriptionSiteCount();
88
        }
89
        if (null !== $object->getSubscriptionEndDate()) {
90
            $data->{'SubscriptionEndDate'} = $object->getSubscriptionEndDate();
91
        }
92
        if (null !== $object->getSubscriptionStartDate()) {
93
            $data->{'SubscriptionStartDate'} = $object->getSubscriptionStartDate();
94
        }
95
        if (null !== $object->getIsAccountWhitelisted()) {
96
            $data->{'IsAccountWhitelisted'} = $object->getIsAccountWhitelisted();
97
        }
98
        if (null !== $object->getUsedScanCreditCount()) {
99
            $data->{'UsedScanCreditCount'} = $object->getUsedScanCreditCount();
100
        }
101
        if (null !== $object->getScanCreditCount()) {
102
            $data->{'ScanCreditCount'} = $object->getScanCreditCount();
103
        }
104
        if (null !== $object->getIsCreditScanEnabled()) {
105
            $data->{'IsCreditScanEnabled'} = $object->getIsCreditScanEnabled();
106
        }
107
        if (null !== $object->getIsSubscriptionEnabled()) {
108
            $data->{'IsSubscriptionEnabled'} = $object->getIsSubscriptionEnabled();
109
        }
110
        if (null !== $object->getPreVerifiedWebsites()) {
111
            $values = [];
112
            foreach ($object->getPreVerifiedWebsites() as $value) {
113
                $values[] = $value;
114
            }
115
            $data->{'PreVerifiedWebsites'} = $values;
116
        }
117
118
        return $data;
119
    }
120
}
121