VulnerabilityTemplateNormalizer::denormalize()   F
last analyzed

Complexity

Conditions 11
Paths 513

Size

Total Lines 35
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 35
rs 3.8263
c 0
b 0
f 0
cc 11
nc 513
nop 4

How to fix   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 VulnerabilityTemplateNormalizer 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\\VulnerabilityTemplate';
29
    }
30
31
    public function supportsNormalization($data, $format = null)
32
    {
33
        return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\VulnerabilityTemplate;
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\VulnerabilityTemplate();
42
        if (property_exists($data, 'Actions')) {
43
            $object->setActions($data->{'Actions'});
44
        }
45
        if (property_exists($data, 'ExternalReferences')) {
46
            $object->setExternalReferences($data->{'ExternalReferences'});
47
        }
48
        if (property_exists($data, 'Impact')) {
49
            $object->setImpact($data->{'Impact'});
50
        }
51
        if (property_exists($data, 'ProofOfConcept')) {
52
            $object->setProofOfConcept($data->{'ProofOfConcept'});
53
        }
54
        if (property_exists($data, 'Remedy')) {
55
            $object->setRemedy($data->{'Remedy'});
56
        }
57
        if (property_exists($data, 'RemedyReferences')) {
58
            $object->setRemedyReferences($data->{'RemedyReferences'});
59
        }
60
        if (property_exists($data, 'Skills')) {
61
            $object->setSkills($data->{'Skills'});
62
        }
63
        if (property_exists($data, 'Summary')) {
64
            $object->setSummary($data->{'Summary'});
65
        }
66
        if (property_exists($data, 'Type')) {
67
            $object->setType($data->{'Type'});
68
        }
69
70
        return $object;
71
    }
72
73
    public function normalize($object, $format = null, array $context = [])
74
    {
75
        $data = new \stdClass();
76
        if (null !== $object->getActions()) {
77
            $data->{'Actions'} = $object->getActions();
78
        }
79
        if (null !== $object->getExternalReferences()) {
80
            $data->{'ExternalReferences'} = $object->getExternalReferences();
81
        }
82
        if (null !== $object->getImpact()) {
83
            $data->{'Impact'} = $object->getImpact();
84
        }
85
        if (null !== $object->getProofOfConcept()) {
86
            $data->{'ProofOfConcept'} = $object->getProofOfConcept();
87
        }
88
        if (null !== $object->getRemedy()) {
89
            $data->{'Remedy'} = $object->getRemedy();
90
        }
91
        if (null !== $object->getRemedyReferences()) {
92
            $data->{'RemedyReferences'} = $object->getRemedyReferences();
93
        }
94
        if (null !== $object->getSkills()) {
95
            $data->{'Skills'} = $object->getSkills();
96
        }
97
        if (null !== $object->getSummary()) {
98
            $data->{'Summary'} = $object->getSummary();
99
        }
100
        if (null !== $object->getType()) {
101
            $data->{'Type'} = $object->getType();
102
        }
103
104
        return $data;
105
    }
106
}
107