UpdateScanPolicySettingModelNormalizer   F
last analyzed

Complexity

Total Complexity 77

Size/Duplication

Total Lines 266
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 77
eloc 175
dl 0
loc 266
rs 2.24
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsDenormalization() 0 3 1
F denormalize() 0 126 38
F normalize() 0 123 37
A supportsNormalization() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like UpdateScanPolicySettingModelNormalizer 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 UpdateScanPolicySettingModelNormalizer, 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 UpdateScanPolicySettingModelNormalizer 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\\UpdateScanPolicySettingModel';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\UpdateScanPolicySettingModel;
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\UpdateScanPolicySettingModel();
42
        if (property_exists($data, 'Id')) {
43
            $object->setId($data->{'Id'});
44
        }
45
        if (property_exists($data, 'IsShared')) {
46
            $object->setIsShared($data->{'IsShared'});
47
        }
48
        if (property_exists($data, 'DesktopId')) {
49
            $object->setDesktopId($data->{'DesktopId'});
50
        }
51
        if (property_exists($data, 'AttackingSettings')) {
52
            $object->setAttackingSettings($this->denormalizer->denormalize($data->{'AttackingSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AttackingSettingModel', 'json', $context));
53
        }
54
        if (property_exists($data, 'AutoCompleteSettings')) {
55
            $values = [];
56
            foreach ($data->{'AutoCompleteSettings'} as $value) {
57
                $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AutoCompleteSettingModel', 'json', $context);
58
            }
59
            $object->setAutoCompleteSettings($values);
60
        }
61
        if (property_exists($data, 'BruteForceSettings')) {
62
            $object->setBruteForceSettings($this->denormalizer->denormalize($data->{'BruteForceSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\BruteForceSettingModel', 'json', $context));
63
        }
64
        if (property_exists($data, 'CrawlingSettings')) {
65
            $object->setCrawlingSettings($this->denormalizer->denormalize($data->{'CrawlingSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\CrawlingSettingModel', 'json', $context));
66
        }
67
        if (property_exists($data, 'CsrfSettings')) {
68
            $object->setCsrfSettings($this->denormalizer->denormalize($data->{'CsrfSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\CsrfSettingModel', 'json', $context));
69
        }
70
        if (property_exists($data, 'Custom404Settings')) {
71
            $object->setCustom404Settings($this->denormalizer->denormalize($data->{'Custom404Settings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\Custom404SettingModel', 'json', $context));
72
        }
73
        if (property_exists($data, 'CustomHttpHeaderSettings')) {
74
            $values_1 = [];
75
            foreach ($data->{'CustomHttpHeaderSettings'} as $value_1) {
76
                $values_1[] = $this->denormalizer->denormalize($value_1, 'Montross50\\NetsparkerCloud\\SDK\\Model\\CustomHttpHeaderSetting', 'json', $context);
77
            }
78
            $object->setCustomHttpHeaderSettings($values_1);
79
        }
80
        if (property_exists($data, 'Description')) {
81
            $object->setDescription($data->{'Description'});
82
        }
83
        if (property_exists($data, 'EnableKnowledgebase')) {
84
            $object->setEnableKnowledgebase($data->{'EnableKnowledgebase'});
85
        }
86
        if (property_exists($data, 'FormValueSettings')) {
87
            $values_2 = [];
88
            foreach ($data->{'FormValueSettings'} as $value_2) {
89
                $values_2[] = $this->denormalizer->denormalize($value_2, 'Montross50\\NetsparkerCloud\\SDK\\Model\\FormValueSettingModel', 'json', $context);
90
            }
91
            $object->setFormValueSettings($values_2);
92
        }
93
        if (property_exists($data, 'HttpRequestSettings')) {
94
            $object->setHttpRequestSettings($this->denormalizer->denormalize($data->{'HttpRequestSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\HttpRequestSettingModel', 'json', $context));
95
        }
96
        if (property_exists($data, 'IgnoredEmailPatterns')) {
97
            $values_3 = [];
98
            foreach ($data->{'IgnoredEmailPatterns'} as $value_3) {
99
                $values_3[] = $this->denormalizer->denormalize($value_3, 'Montross50\\NetsparkerCloud\\SDK\\Model\\EmailPatternSetting', 'json', $context);
100
            }
101
            $object->setIgnoredEmailPatterns($values_3);
102
        }
103
        if (property_exists($data, 'IgnorePatternSettings')) {
104
            $values_4 = [];
105
            foreach ($data->{'IgnorePatternSettings'} as $value_4) {
106
                $values_4[] = $this->denormalizer->denormalize($value_4, 'Montross50\\NetsparkerCloud\\SDK\\Model\\IgnorePatternSettingModel', 'json', $context);
107
            }
108
            $object->setIgnorePatternSettings($values_4);
109
        }
110
        if (property_exists($data, 'JavaScriptSettings')) {
111
            $object->setJavaScriptSettings($this->denormalizer->denormalize($data->{'JavaScriptSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\JavaScriptSettingsModel', 'json', $context));
112
        }
113
        if (property_exists($data, 'Name')) {
114
            $object->setName($data->{'Name'});
115
        }
116
        if (property_exists($data, 'ProxySettings')) {
117
            $object->setProxySettings($this->denormalizer->denormalize($data->{'ProxySettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ProxySettingsModel', 'json', $context));
118
        }
119
        if (property_exists($data, 'ScopeSettings')) {
120
            $object->setScopeSettings($this->denormalizer->denormalize($data->{'ScopeSettings'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScopeSettingModel', 'json', $context));
121
        }
122
        if (property_exists($data, 'SecurityCheckGroups')) {
123
            $values_5 = [];
124
            foreach ($data->{'SecurityCheckGroups'} as $value_5) {
125
                $values_5[] = $this->denormalizer->denormalize($value_5, 'Montross50\\NetsparkerCloud\\SDK\\Model\\SecurityCheckGroupModel', 'json', $context);
126
            }
127
            $object->setSecurityCheckGroups($values_5);
128
        }
129
        if (property_exists($data, 'SelectedGroups')) {
130
            $values_6 = [];
131
            foreach ($data->{'SelectedGroups'} as $value_6) {
132
                $values_6[] = $value_6;
133
            }
134
            $object->setSelectedGroups($values_6);
135
        }
136
        if (property_exists($data, 'SensitiveKeywordSettings')) {
137
            $values_7 = [];
138
            foreach ($data->{'SensitiveKeywordSettings'} as $value_7) {
139
                $values_7[] = $this->denormalizer->denormalize($value_7, 'Montross50\\NetsparkerCloud\\SDK\\Model\\SensitiveKeywordSettingModel', 'json', $context);
140
            }
141
            $object->setSensitiveKeywordSettings($values_7);
142
        }
143
        if (property_exists($data, 'SslTlsSettingModel')) {
144
            $object->setSslTlsSettingModel($this->denormalizer->denormalize($data->{'SslTlsSettingModel'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\SslTlsSettingModel', 'json', $context));
145
        }
146
        if (property_exists($data, 'WebStorageSettings')) {
147
            $values_8 = [];
148
            foreach ($data->{'WebStorageSettings'} as $value_8) {
149
                $values_8[] = $this->denormalizer->denormalize($value_8, 'Montross50\\NetsparkerCloud\\SDK\\Model\\WebStorageSetting', 'json', $context);
150
            }
151
            $object->setWebStorageSettings($values_8);
152
        }
153
        if (property_exists($data, 'ExtensionSettings')) {
154
            $values_9 = [];
155
            foreach ($data->{'ExtensionSettings'} as $value_9) {
156
                $values_9[] = $this->denormalizer->denormalize($value_9, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ExtensionSettingModel', 'json', $context);
157
            }
158
            $object->setExtensionSettings($values_9);
159
        }
160
161
        return $object;
162
    }
163
164
    public function normalize($object, $format = null, array $context = [])
165
    {
166
        $data = new \stdClass();
167
        if (null !== $object->getId()) {
168
            $data->{'Id'} = $object->getId();
169
        }
170
        if (null !== $object->getIsShared()) {
171
            $data->{'IsShared'} = $object->getIsShared();
172
        }
173
        if (null !== $object->getDesktopId()) {
174
            $data->{'DesktopId'} = $object->getDesktopId();
175
        }
176
        if (null !== $object->getAttackingSettings()) {
177
            $data->{'AttackingSettings'} = $this->normalizer->normalize($object->getAttackingSettings(), 'json', $context);
178
        }
179
        if (null !== $object->getAutoCompleteSettings()) {
180
            $values = [];
181
            foreach ($object->getAutoCompleteSettings() as $value) {
182
                $values[] = $this->normalizer->normalize($value, 'json', $context);
183
            }
184
            $data->{'AutoCompleteSettings'} = $values;
185
        }
186
        if (null !== $object->getBruteForceSettings()) {
187
            $data->{'BruteForceSettings'} = $this->normalizer->normalize($object->getBruteForceSettings(), 'json', $context);
188
        }
189
        if (null !== $object->getCrawlingSettings()) {
190
            $data->{'CrawlingSettings'} = $this->normalizer->normalize($object->getCrawlingSettings(), 'json', $context);
191
        }
192
        if (null !== $object->getCsrfSettings()) {
193
            $data->{'CsrfSettings'} = $this->normalizer->normalize($object->getCsrfSettings(), 'json', $context);
194
        }
195
        if (null !== $object->getCustom404Settings()) {
196
            $data->{'Custom404Settings'} = $this->normalizer->normalize($object->getCustom404Settings(), 'json', $context);
197
        }
198
        if (null !== $object->getCustomHttpHeaderSettings()) {
199
            $values_1 = [];
200
            foreach ($object->getCustomHttpHeaderSettings() as $value_1) {
201
                $values_1[] = $this->normalizer->normalize($value_1, 'json', $context);
202
            }
203
            $data->{'CustomHttpHeaderSettings'} = $values_1;
204
        }
205
        if (null !== $object->getDescription()) {
206
            $data->{'Description'} = $object->getDescription();
207
        }
208
        if (null !== $object->getEnableKnowledgebase()) {
209
            $data->{'EnableKnowledgebase'} = $object->getEnableKnowledgebase();
210
        }
211
        if (null !== $object->getFormValueSettings()) {
212
            $values_2 = [];
213
            foreach ($object->getFormValueSettings() as $value_2) {
214
                $values_2[] = $this->normalizer->normalize($value_2, 'json', $context);
215
            }
216
            $data->{'FormValueSettings'} = $values_2;
217
        }
218
        if (null !== $object->getHttpRequestSettings()) {
219
            $data->{'HttpRequestSettings'} = $this->normalizer->normalize($object->getHttpRequestSettings(), 'json', $context);
220
        }
221
        if (null !== $object->getIgnoredEmailPatterns()) {
222
            $values_3 = [];
223
            foreach ($object->getIgnoredEmailPatterns() as $value_3) {
224
                $values_3[] = $this->normalizer->normalize($value_3, 'json', $context);
225
            }
226
            $data->{'IgnoredEmailPatterns'} = $values_3;
227
        }
228
        if (null !== $object->getIgnorePatternSettings()) {
229
            $values_4 = [];
230
            foreach ($object->getIgnorePatternSettings() as $value_4) {
231
                $values_4[] = $this->normalizer->normalize($value_4, 'json', $context);
232
            }
233
            $data->{'IgnorePatternSettings'} = $values_4;
234
        }
235
        if (null !== $object->getJavaScriptSettings()) {
236
            $data->{'JavaScriptSettings'} = $this->normalizer->normalize($object->getJavaScriptSettings(), 'json', $context);
237
        }
238
        if (null !== $object->getName()) {
239
            $data->{'Name'} = $object->getName();
240
        }
241
        if (null !== $object->getProxySettings()) {
242
            $data->{'ProxySettings'} = $this->normalizer->normalize($object->getProxySettings(), 'json', $context);
243
        }
244
        if (null !== $object->getScopeSettings()) {
245
            $data->{'ScopeSettings'} = $this->normalizer->normalize($object->getScopeSettings(), 'json', $context);
246
        }
247
        if (null !== $object->getSecurityCheckGroups()) {
248
            $values_5 = [];
249
            foreach ($object->getSecurityCheckGroups() as $value_5) {
250
                $values_5[] = $this->normalizer->normalize($value_5, 'json', $context);
251
            }
252
            $data->{'SecurityCheckGroups'} = $values_5;
253
        }
254
        if (null !== $object->getSelectedGroups()) {
255
            $values_6 = [];
256
            foreach ($object->getSelectedGroups() as $value_6) {
257
                $values_6[] = $value_6;
258
            }
259
            $data->{'SelectedGroups'} = $values_6;
260
        }
261
        if (null !== $object->getSensitiveKeywordSettings()) {
262
            $values_7 = [];
263
            foreach ($object->getSensitiveKeywordSettings() as $value_7) {
264
                $values_7[] = $this->normalizer->normalize($value_7, 'json', $context);
265
            }
266
            $data->{'SensitiveKeywordSettings'} = $values_7;
267
        }
268
        if (null !== $object->getSslTlsSettingModel()) {
269
            $data->{'SslTlsSettingModel'} = $this->normalizer->normalize($object->getSslTlsSettingModel(), 'json', $context);
270
        }
271
        if (null !== $object->getWebStorageSettings()) {
272
            $values_8 = [];
273
            foreach ($object->getWebStorageSettings() as $value_8) {
274
                $values_8[] = $this->normalizer->normalize($value_8, 'json', $context);
275
            }
276
            $data->{'WebStorageSettings'} = $values_8;
277
        }
278
        if (null !== $object->getExtensionSettings()) {
279
            $values_9 = [];
280
            foreach ($object->getExtensionSettings() as $value_9) {
281
                $values_9[] = $this->normalizer->normalize($value_9, 'json', $context);
282
            }
283
            $data->{'ExtensionSettings'} = $values_9;
284
        }
285
286
        return $data;
287
    }
288
}
289