NewScanTaskApiModelNormalizer::denormalize()   F
last analyzed

Complexity

Conditions 35
Paths > 20000

Size

Total Lines 113
Code Lines 76

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 76
dl 0
loc 113
rs 0
c 0
b 0
f 0
cc 35
nc 134217729
nop 4

How to fix   Long Method    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 NewScanTaskApiModelNormalizer 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\\NewScanTaskApiModel';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\NewScanTaskApiModel;
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\NewScanTaskApiModel();
42
        if (property_exists($data, 'TargetUri')) {
43
            $object->setTargetUri($data->{'TargetUri'});
44
        }
45
        if (property_exists($data, 'AdditionalWebsites')) {
46
            $values = [];
47
            foreach ($data->{'AdditionalWebsites'} as $value) {
48
                $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AdditionalWebsiteModel', 'json', $context);
49
            }
50
            $object->setAdditionalWebsites($values);
51
        }
52
        if (property_exists($data, 'BasicAuthenticationApiModel')) {
53
            $object->setBasicAuthenticationApiModel($this->denormalizer->denormalize($data->{'BasicAuthenticationApiModel'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\BasicAuthenticationSettingModel', 'json', $context));
54
        }
55
        if (property_exists($data, 'ClientCertificateAuthenticationSetting')) {
56
            $object->setClientCertificateAuthenticationSetting($this->denormalizer->denormalize($data->{'ClientCertificateAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ClientCertificateAuthenticationApiModel', 'json', $context));
57
        }
58
        if (property_exists($data, 'Cookies')) {
59
            $object->setCookies($data->{'Cookies'});
60
        }
61
        if (property_exists($data, 'CrawlAndAttack')) {
62
            $object->setCrawlAndAttack($data->{'CrawlAndAttack'});
63
        }
64
        if (property_exists($data, 'EnableHeuristicChecksInCustomUrlRewrite')) {
65
            $object->setEnableHeuristicChecksInCustomUrlRewrite($data->{'EnableHeuristicChecksInCustomUrlRewrite'});
66
        }
67
        if (property_exists($data, 'ExcludedLinks')) {
68
            $values_1 = [];
69
            foreach ($data->{'ExcludedLinks'} as $value_1) {
70
                $values_1[] = $this->denormalizer->denormalize($value_1, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ExcludedLinkModel', 'json', $context);
71
            }
72
            $object->setExcludedLinks($values_1);
73
        }
74
        if (property_exists($data, 'DisallowedHttpMethods')) {
75
            $values_2 = [];
76
            foreach ($data->{'DisallowedHttpMethods'} as $value_2) {
77
                $values_2[] = $value_2;
78
            }
79
            $object->setDisallowedHttpMethods($values_2);
80
        }
81
        if (property_exists($data, 'ExcludeLinks')) {
82
            $object->setExcludeLinks($data->{'ExcludeLinks'});
83
        }
84
        if (property_exists($data, 'FindAndFollowNewLinks')) {
85
            $object->setFindAndFollowNewLinks($data->{'FindAndFollowNewLinks'});
86
        }
87
        if (property_exists($data, 'FormAuthenticationSettingModel')) {
88
            $object->setFormAuthenticationSettingModel($this->denormalizer->denormalize($data->{'FormAuthenticationSettingModel'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\FormAuthenticationSettingModel', 'json', $context));
89
        }
90
        if (property_exists($data, 'HeaderAuthentication')) {
91
            $object->setHeaderAuthentication($this->denormalizer->denormalize($data->{'HeaderAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\HeaderAuthenticationModel', 'json', $context));
92
        }
93
        if (property_exists($data, 'ImportedLinks')) {
94
            $values_3 = [];
95
            foreach ($data->{'ImportedLinks'} as $value_3) {
96
                $values_3[] = $value_3;
97
            }
98
            $object->setImportedLinks($values_3);
99
        }
100
        if (property_exists($data, 'ImportedFiles')) {
101
            $values_4 = [];
102
            foreach ($data->{'ImportedFiles'} as $value_4) {
103
                $values_4[] = $this->denormalizer->denormalize($value_4, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ApiFileModel', 'json', $context);
104
            }
105
            $object->setImportedFiles($values_4);
106
        }
107
        if (property_exists($data, 'IsMaxScanDurationEnabled')) {
108
            $object->setIsMaxScanDurationEnabled($data->{'IsMaxScanDurationEnabled'});
109
        }
110
        if (property_exists($data, 'MaxDynamicSignatures')) {
111
            $object->setMaxDynamicSignatures($data->{'MaxDynamicSignatures'});
112
        }
113
        if (property_exists($data, 'MaxScanDuration')) {
114
            $object->setMaxScanDuration($data->{'MaxScanDuration'});
115
        }
116
        if (property_exists($data, 'PolicyId')) {
117
            $object->setPolicyId($data->{'PolicyId'});
118
        }
119
        if (property_exists($data, 'ReportPolicyId')) {
120
            $object->setReportPolicyId($data->{'ReportPolicyId'});
121
        }
122
        if (property_exists($data, 'Scope')) {
123
            $object->setScope($data->{'Scope'});
124
        }
125
        if (property_exists($data, 'SubPathMaxDynamicSignatures')) {
126
            $object->setSubPathMaxDynamicSignatures($data->{'SubPathMaxDynamicSignatures'});
127
        }
128
        if (property_exists($data, 'TimeWindow')) {
129
            $object->setTimeWindow($this->denormalizer->denormalize($data->{'TimeWindow'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScanTimeWindowModel', 'json', $context));
130
        }
131
        if (property_exists($data, 'UrlRewriteAnalyzableExtensions')) {
132
            $object->setUrlRewriteAnalyzableExtensions($data->{'UrlRewriteAnalyzableExtensions'});
133
        }
134
        if (property_exists($data, 'UrlRewriteBlockSeparators')) {
135
            $object->setUrlRewriteBlockSeparators($data->{'UrlRewriteBlockSeparators'});
136
        }
137
        if (property_exists($data, 'UrlRewriteMode')) {
138
            $object->setUrlRewriteMode($data->{'UrlRewriteMode'});
139
        }
140
        if (property_exists($data, 'UrlRewriteRules')) {
141
            $values_5 = [];
142
            foreach ($data->{'UrlRewriteRules'} as $value_5) {
143
                $values_5[] = $this->denormalizer->denormalize($value_5, 'Montross50\\NetsparkerCloud\\SDK\\Model\\UrlRewriteRuleModel', 'json', $context);
144
            }
145
            $object->setUrlRewriteRules($values_5);
146
        }
147
148
        return $object;
149
    }
150
151
    public function normalize($object, $format = null, array $context = [])
152
    {
153
        $data = new \stdClass();
154
        if (null !== $object->getTargetUri()) {
155
            $data->{'TargetUri'} = $object->getTargetUri();
156
        }
157
        if (null !== $object->getAdditionalWebsites()) {
158
            $values = [];
159
            foreach ($object->getAdditionalWebsites() as $value) {
160
                $values[] = $this->normalizer->normalize($value, 'json', $context);
161
            }
162
            $data->{'AdditionalWebsites'} = $values;
163
        }
164
        if (null !== $object->getBasicAuthenticationApiModel()) {
165
            $data->{'BasicAuthenticationApiModel'} = $this->normalizer->normalize($object->getBasicAuthenticationApiModel(), 'json', $context);
166
        }
167
        if (null !== $object->getClientCertificateAuthenticationSetting()) {
168
            $data->{'ClientCertificateAuthenticationSetting'} = $this->normalizer->normalize($object->getClientCertificateAuthenticationSetting(), 'json', $context);
169
        }
170
        if (null !== $object->getCookies()) {
171
            $data->{'Cookies'} = $object->getCookies();
172
        }
173
        if (null !== $object->getCrawlAndAttack()) {
174
            $data->{'CrawlAndAttack'} = $object->getCrawlAndAttack();
175
        }
176
        if (null !== $object->getEnableHeuristicChecksInCustomUrlRewrite()) {
177
            $data->{'EnableHeuristicChecksInCustomUrlRewrite'} = $object->getEnableHeuristicChecksInCustomUrlRewrite();
178
        }
179
        if (null !== $object->getExcludedLinks()) {
180
            $values_1 = [];
181
            foreach ($object->getExcludedLinks() as $value_1) {
182
                $values_1[] = $this->normalizer->normalize($value_1, 'json', $context);
183
            }
184
            $data->{'ExcludedLinks'} = $values_1;
185
        }
186
        if (null !== $object->getDisallowedHttpMethods()) {
187
            $values_2 = [];
188
            foreach ($object->getDisallowedHttpMethods() as $value_2) {
189
                $values_2[] = $value_2;
190
            }
191
            $data->{'DisallowedHttpMethods'} = $values_2;
192
        }
193
        if (null !== $object->getExcludeLinks()) {
194
            $data->{'ExcludeLinks'} = $object->getExcludeLinks();
195
        }
196
        if (null !== $object->getFindAndFollowNewLinks()) {
197
            $data->{'FindAndFollowNewLinks'} = $object->getFindAndFollowNewLinks();
198
        }
199
        if (null !== $object->getFormAuthenticationSettingModel()) {
200
            $data->{'FormAuthenticationSettingModel'} = $this->normalizer->normalize($object->getFormAuthenticationSettingModel(), 'json', $context);
201
        }
202
        if (null !== $object->getHeaderAuthentication()) {
203
            $data->{'HeaderAuthentication'} = $this->normalizer->normalize($object->getHeaderAuthentication(), 'json', $context);
204
        }
205
        if (null !== $object->getImportedLinks()) {
206
            $values_3 = [];
207
            foreach ($object->getImportedLinks() as $value_3) {
208
                $values_3[] = $value_3;
209
            }
210
            $data->{'ImportedLinks'} = $values_3;
211
        }
212
        if (null !== $object->getImportedFiles()) {
213
            $values_4 = [];
214
            foreach ($object->getImportedFiles() as $value_4) {
215
                $values_4[] = $this->normalizer->normalize($value_4, 'json', $context);
216
            }
217
            $data->{'ImportedFiles'} = $values_4;
218
        }
219
        if (null !== $object->getIsMaxScanDurationEnabled()) {
220
            $data->{'IsMaxScanDurationEnabled'} = $object->getIsMaxScanDurationEnabled();
221
        }
222
        if (null !== $object->getMaxDynamicSignatures()) {
223
            $data->{'MaxDynamicSignatures'} = $object->getMaxDynamicSignatures();
224
        }
225
        if (null !== $object->getMaxScanDuration()) {
226
            $data->{'MaxScanDuration'} = $object->getMaxScanDuration();
227
        }
228
        if (null !== $object->getPolicyId()) {
229
            $data->{'PolicyId'} = $object->getPolicyId();
230
        }
231
        if (null !== $object->getReportPolicyId()) {
232
            $data->{'ReportPolicyId'} = $object->getReportPolicyId();
233
        }
234
        if (null !== $object->getScope()) {
235
            $data->{'Scope'} = $object->getScope();
236
        }
237
        if (null !== $object->getSubPathMaxDynamicSignatures()) {
238
            $data->{'SubPathMaxDynamicSignatures'} = $object->getSubPathMaxDynamicSignatures();
239
        }
240
        if (null !== $object->getTimeWindow()) {
241
            $data->{'TimeWindow'} = $this->normalizer->normalize($object->getTimeWindow(), 'json', $context);
242
        }
243
        if (null !== $object->getUrlRewriteAnalyzableExtensions()) {
244
            $data->{'UrlRewriteAnalyzableExtensions'} = $object->getUrlRewriteAnalyzableExtensions();
245
        }
246
        if (null !== $object->getUrlRewriteBlockSeparators()) {
247
            $data->{'UrlRewriteBlockSeparators'} = $object->getUrlRewriteBlockSeparators();
248
        }
249
        if (null !== $object->getUrlRewriteMode()) {
250
            $data->{'UrlRewriteMode'} = $object->getUrlRewriteMode();
251
        }
252
        if (null !== $object->getUrlRewriteRules()) {
253
            $values_5 = [];
254
            foreach ($object->getUrlRewriteRules() as $value_5) {
255
                $values_5[] = $this->normalizer->normalize($value_5, 'json', $context);
256
            }
257
            $data->{'UrlRewriteRules'} = $values_5;
258
        }
259
260
        return $data;
261
    }
262
}
263