denormalize()   D
last analyzed

Complexity

Conditions 40

Size

Total Lines 128
Code Lines 86

Duplication

Lines 0
Ratio 0 %

Importance

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