NewScanPolicySettingModelNormalizer::normalize()   F
last analyzed

Complexity

Conditions 36
Paths > 20000

Size

Total Lines 120
Code Lines 82

Duplication

Lines 0
Ratio 0 %

Importance

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