ScheduledScanModelNormalizer   F
last analyzed

Complexity

Total Complexity 97

Size/Duplication

Total Lines 308
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 97
eloc 197
dl 0
loc 308
rs 2
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsNormalization() 0 3 1
A supportsDenormalization() 0 3 1
D normalize() 0 144 47
D denormalize() 0 147 48

How to fix   Complexity   

Complex Class

Complex classes like ScheduledScanModelNormalizer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ScheduledScanModelNormalizer, and based on these observations, apply Extract Interface, too.

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