UpdateScheduledScanModelNormalizer::normalize()   D
last analyzed

Complexity

Conditions 44

Size

Total Lines 135
Code Lines 89

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 89
dl 0
loc 135
rs 4.1666
c 0
b 0
f 0
cc 44
nop 3

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 UpdateScheduledScanModelNormalizer 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\\UpdateScheduledScanModel';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\UpdateScheduledScanModel;
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\UpdateScheduledScanModel();
42
        if (property_exists($data, 'Id')) {
43
            $object->setId($data->{'Id'});
44
        }
45
        if (property_exists($data, 'OccurencesCount')) {
46
            $object->setOccurencesCount($data->{'OccurencesCount'});
47
        }
48
        if (property_exists($data, 'Disabled')) {
49
            $object->setDisabled($data->{'Disabled'});
50
        }
51
        if (property_exists($data, 'EnableScheduling')) {
52
            $object->setEnableScheduling($data->{'EnableScheduling'});
53
        }
54
        if (property_exists($data, 'Name')) {
55
            $object->setName($data->{'Name'});
56
        }
57
        if (property_exists($data, 'NextExecutionTime')) {
58
            $object->setNextExecutionTime($data->{'NextExecutionTime'});
59
        }
60
        if (property_exists($data, 'ScanGroupId')) {
61
            $object->setScanGroupId($data->{'ScanGroupId'});
62
        }
63
        if (property_exists($data, 'ScanType')) {
64
            $object->setScanType($data->{'ScanType'});
65
        }
66
        if (property_exists($data, 'ScheduleRunType')) {
67
            $object->setScheduleRunType($data->{'ScheduleRunType'});
68
        }
69
        if (property_exists($data, 'CustomRecurrence')) {
70
            $object->setCustomRecurrence($this->denormalizer->denormalize($data->{'CustomRecurrence'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScheduledScanRecurrenceViewModel', 'json', $context));
71
        }
72
        if (property_exists($data, 'IsTargetUrlRequired')) {
73
            $object->setIsTargetUrlRequired($data->{'IsTargetUrlRequired'});
74
        }
75
        if (property_exists($data, 'AdditionalWebsites')) {
76
            $object->setAdditionalWebsites($this->denormalizer->denormalize($data->{'AdditionalWebsites'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AdditionalWebsitesSettingModel', 'json', $context));
77
        }
78
        if (property_exists($data, 'AgentGroupId')) {
79
            $object->setAgentGroupId($data->{'AgentGroupId'});
80
        }
81
        if (property_exists($data, 'AgentId')) {
82
            $object->setAgentId($data->{'AgentId'});
83
        }
84
        if (property_exists($data, 'BasicAuthenticationSetting')) {
85
            $object->setBasicAuthenticationSetting($this->denormalizer->denormalize($data->{'BasicAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\BasicAuthenticationSettingModel', 'json', $context));
86
        }
87
        if (property_exists($data, 'CanEdit')) {
88
            $object->setCanEdit($data->{'CanEdit'});
89
        }
90
        if (property_exists($data, 'ClientCertificateAuthentication')) {
91
            $object->setClientCertificateAuthentication($this->denormalizer->denormalize($data->{'ClientCertificateAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ClientCertificateAuthenticationViewModel', 'json', $context));
92
        }
93
        if (property_exists($data, 'Cookies')) {
94
            $object->setCookies($data->{'Cookies'});
95
        }
96
        if (property_exists($data, 'CrawlAndAttack')) {
97
            $object->setCrawlAndAttack($data->{'CrawlAndAttack'});
98
        }
99
        if (property_exists($data, 'CreateType')) {
100
            $object->setCreateType($data->{'CreateType'});
101
        }
102
        if (property_exists($data, 'FindAndFollowNewLinks')) {
103
            $object->setFindAndFollowNewLinks($data->{'FindAndFollowNewLinks'});
104
        }
105
        if (property_exists($data, 'FormAuthenticationSetting')) {
106
            $object->setFormAuthenticationSetting($this->denormalizer->denormalize($data->{'FormAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\FormAuthenticationSettingModel', 'json', $context));
107
        }
108
        if (property_exists($data, 'HeaderAuthentication')) {
109
            $object->setHeaderAuthentication($this->denormalizer->denormalize($data->{'HeaderAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\HeaderAuthenticationModel', 'json', $context));
110
        }
111
        if (property_exists($data, 'ImportedLinks')) {
112
            $object->setImportedLinks($this->denormalizer->denormalize($data->{'ImportedLinks'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ImportedLinksSetting', 'json', $context));
113
        }
114
        if (property_exists($data, 'IsMaxScanDurationEnabled')) {
115
            $object->setIsMaxScanDurationEnabled($data->{'IsMaxScanDurationEnabled'});
116
        }
117
        if (property_exists($data, 'IsPrimary')) {
118
            $object->setIsPrimary($data->{'IsPrimary'});
119
        }
120
        if (property_exists($data, 'IsShared')) {
121
            $object->setIsShared($data->{'IsShared'});
122
        }
123
        if (property_exists($data, 'MaxScanDuration')) {
124
            $object->setMaxScanDuration($data->{'MaxScanDuration'});
125
        }
126
        if (property_exists($data, 'PolicyId')) {
127
            $object->setPolicyId($data->{'PolicyId'});
128
        }
129
        if (property_exists($data, 'ProfileId')) {
130
            $object->setProfileId($data->{'ProfileId'});
131
        }
132
        if (property_exists($data, 'ProfileName')) {
133
            $object->setProfileName($data->{'ProfileName'});
134
        }
135
        if (property_exists($data, 'ReportPolicyId')) {
136
            $object->setReportPolicyId($data->{'ReportPolicyId'});
137
        }
138
        if (property_exists($data, 'SaveScanProfile')) {
139
            $object->setSaveScanProfile($data->{'SaveScanProfile'});
140
        }
141
        if (property_exists($data, 'ScopeSetting')) {
142
            $object->setScopeSetting($this->denormalizer->denormalize($data->{'ScopeSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScopeSetting', 'json', $context));
143
        }
144
        if (property_exists($data, 'SelectedAgents')) {
145
            $values = [];
146
            foreach ($data->{'SelectedAgents'} as $value) {
147
                $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AgentSelectionModel', 'json', $context);
148
            }
149
            $object->setSelectedAgents($values);
150
        }
151
        if (property_exists($data, 'SelectedScanProfileId')) {
152
            $object->setSelectedScanProfileId($data->{'SelectedScanProfileId'});
153
        }
154
        if (property_exists($data, 'SelectedScanProfileName')) {
155
            $object->setSelectedScanProfileName($data->{'SelectedScanProfileName'});
156
        }
157
        if (property_exists($data, 'TargetUrl')) {
158
            $object->setTargetUrl($data->{'TargetUrl'});
159
        }
160
        if (property_exists($data, 'TimeWindow')) {
161
            $object->setTimeWindow($this->denormalizer->denormalize($data->{'TimeWindow'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScanTimeWindowViewModel', 'json', $context));
162
        }
163
        if (property_exists($data, 'UrlRewriteSetting')) {
164
            $object->setUrlRewriteSetting($this->denormalizer->denormalize($data->{'UrlRewriteSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\UrlRewriteSetting', 'json', $context));
165
        }
166
        if (property_exists($data, 'UserId')) {
167
            $object->setUserId($data->{'UserId'});
168
        }
169
        if (property_exists($data, 'WebsiteGroupId')) {
170
            $object->setWebsiteGroupId($data->{'WebsiteGroupId'});
171
        }
172
173
        return $object;
174
    }
175
176
    public function normalize($object, $format = null, array $context = [])
177
    {
178
        $data = new \stdClass();
179
        if (null !== $object->getId()) {
180
            $data->{'Id'} = $object->getId();
181
        }
182
        if (null !== $object->getOccurencesCount()) {
183
            $data->{'OccurencesCount'} = $object->getOccurencesCount();
184
        }
185
        if (null !== $object->getDisabled()) {
186
            $data->{'Disabled'} = $object->getDisabled();
187
        }
188
        if (null !== $object->getEnableScheduling()) {
189
            $data->{'EnableScheduling'} = $object->getEnableScheduling();
190
        }
191
        if (null !== $object->getName()) {
192
            $data->{'Name'} = $object->getName();
193
        }
194
        if (null !== $object->getNextExecutionTime()) {
195
            $data->{'NextExecutionTime'} = $object->getNextExecutionTime();
196
        }
197
        if (null !== $object->getScanGroupId()) {
198
            $data->{'ScanGroupId'} = $object->getScanGroupId();
199
        }
200
        if (null !== $object->getScanType()) {
201
            $data->{'ScanType'} = $object->getScanType();
202
        }
203
        if (null !== $object->getScheduleRunType()) {
204
            $data->{'ScheduleRunType'} = $object->getScheduleRunType();
205
        }
206
        if (null !== $object->getCustomRecurrence()) {
207
            $data->{'CustomRecurrence'} = $this->normalizer->normalize($object->getCustomRecurrence(), 'json', $context);
208
        }
209
        if (null !== $object->getIsTargetUrlRequired()) {
210
            $data->{'IsTargetUrlRequired'} = $object->getIsTargetUrlRequired();
211
        }
212
        if (null !== $object->getAdditionalWebsites()) {
213
            $data->{'AdditionalWebsites'} = $this->normalizer->normalize($object->getAdditionalWebsites(), 'json', $context);
214
        }
215
        if (null !== $object->getAgentGroupId()) {
216
            $data->{'AgentGroupId'} = $object->getAgentGroupId();
217
        }
218
        if (null !== $object->getAgentId()) {
219
            $data->{'AgentId'} = $object->getAgentId();
220
        }
221
        if (null !== $object->getBasicAuthenticationSetting()) {
222
            $data->{'BasicAuthenticationSetting'} = $this->normalizer->normalize($object->getBasicAuthenticationSetting(), 'json', $context);
223
        }
224
        if (null !== $object->getCanEdit()) {
225
            $data->{'CanEdit'} = $object->getCanEdit();
226
        }
227
        if (null !== $object->getClientCertificateAuthentication()) {
228
            $data->{'ClientCertificateAuthentication'} = $this->normalizer->normalize($object->getClientCertificateAuthentication(), 'json', $context);
229
        }
230
        if (null !== $object->getCookies()) {
231
            $data->{'Cookies'} = $object->getCookies();
232
        }
233
        if (null !== $object->getCrawlAndAttack()) {
234
            $data->{'CrawlAndAttack'} = $object->getCrawlAndAttack();
235
        }
236
        if (null !== $object->getCreateType()) {
237
            $data->{'CreateType'} = $object->getCreateType();
238
        }
239
        if (null !== $object->getFindAndFollowNewLinks()) {
240
            $data->{'FindAndFollowNewLinks'} = $object->getFindAndFollowNewLinks();
241
        }
242
        if (null !== $object->getFormAuthenticationSetting()) {
243
            $data->{'FormAuthenticationSetting'} = $this->normalizer->normalize($object->getFormAuthenticationSetting(), 'json', $context);
244
        }
245
        if (null !== $object->getHeaderAuthentication()) {
246
            $data->{'HeaderAuthentication'} = $this->normalizer->normalize($object->getHeaderAuthentication(), 'json', $context);
247
        }
248
        if (null !== $object->getImportedLinks()) {
249
            $data->{'ImportedLinks'} = $this->normalizer->normalize($object->getImportedLinks(), 'json', $context);
250
        }
251
        if (null !== $object->getIsMaxScanDurationEnabled()) {
252
            $data->{'IsMaxScanDurationEnabled'} = $object->getIsMaxScanDurationEnabled();
253
        }
254
        if (null !== $object->getIsPrimary()) {
255
            $data->{'IsPrimary'} = $object->getIsPrimary();
256
        }
257
        if (null !== $object->getIsShared()) {
258
            $data->{'IsShared'} = $object->getIsShared();
259
        }
260
        if (null !== $object->getMaxScanDuration()) {
261
            $data->{'MaxScanDuration'} = $object->getMaxScanDuration();
262
        }
263
        if (null !== $object->getPolicyId()) {
264
            $data->{'PolicyId'} = $object->getPolicyId();
265
        }
266
        if (null !== $object->getProfileId()) {
267
            $data->{'ProfileId'} = $object->getProfileId();
268
        }
269
        if (null !== $object->getProfileName()) {
270
            $data->{'ProfileName'} = $object->getProfileName();
271
        }
272
        if (null !== $object->getReportPolicyId()) {
273
            $data->{'ReportPolicyId'} = $object->getReportPolicyId();
274
        }
275
        if (null !== $object->getSaveScanProfile()) {
276
            $data->{'SaveScanProfile'} = $object->getSaveScanProfile();
277
        }
278
        if (null !== $object->getScopeSetting()) {
279
            $data->{'ScopeSetting'} = $this->normalizer->normalize($object->getScopeSetting(), 'json', $context);
280
        }
281
        if (null !== $object->getSelectedAgents()) {
282
            $values = [];
283
            foreach ($object->getSelectedAgents() as $value) {
284
                $values[] = $this->normalizer->normalize($value, 'json', $context);
285
            }
286
            $data->{'SelectedAgents'} = $values;
287
        }
288
        if (null !== $object->getSelectedScanProfileId()) {
289
            $data->{'SelectedScanProfileId'} = $object->getSelectedScanProfileId();
290
        }
291
        if (null !== $object->getSelectedScanProfileName()) {
292
            $data->{'SelectedScanProfileName'} = $object->getSelectedScanProfileName();
293
        }
294
        if (null !== $object->getTargetUrl()) {
295
            $data->{'TargetUrl'} = $object->getTargetUrl();
296
        }
297
        if (null !== $object->getTimeWindow()) {
298
            $data->{'TimeWindow'} = $this->normalizer->normalize($object->getTimeWindow(), 'json', $context);
299
        }
300
        if (null !== $object->getUrlRewriteSetting()) {
301
            $data->{'UrlRewriteSetting'} = $this->normalizer->normalize($object->getUrlRewriteSetting(), 'json', $context);
302
        }
303
        if (null !== $object->getUserId()) {
304
            $data->{'UserId'} = $object->getUserId();
305
        }
306
        if (null !== $object->getWebsiteGroupId()) {
307
            $data->{'WebsiteGroupId'} = $object->getWebsiteGroupId();
308
        }
309
310
        return $data;
311
    }
312
}
313