ScanPolicySettingApiModelNormalizer::denormalize()   F
last analyzed

Complexity

Conditions 39
Paths > 20000

Size

Total Lines 129
Code Lines 88

Duplication

Lines 0
Ratio 0 %

Importance

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