| Total Complexity | 77 |
| Total Lines | 258 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like NewScheduledScanApiModelNormalizer 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 NewScheduledScanApiModelNormalizer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class NewScheduledScanApiModelNormalizer 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\\NewScheduledScanApiModel'; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function supportsNormalization($data, $format = null) |
||
| 32 | { |
||
| 33 | return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\NewScheduledScanApiModel; |
||
| 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\NewScheduledScanApiModel(); |
||
| 42 | if (property_exists($data, 'Name')) { |
||
| 43 | $object->setName($data->{'Name'}); |
||
| 44 | } |
||
| 45 | if (property_exists($data, 'NextExecutionTime')) { |
||
| 46 | $object->setNextExecutionTime($data->{'NextExecutionTime'}); |
||
| 47 | } |
||
| 48 | if (property_exists($data, 'ScheduleRunType')) { |
||
| 49 | $object->setScheduleRunType($data->{'ScheduleRunType'}); |
||
| 50 | } |
||
| 51 | if (property_exists($data, 'TargetUri')) { |
||
| 52 | $object->setTargetUri($data->{'TargetUri'}); |
||
| 53 | } |
||
| 54 | if (property_exists($data, 'AdditionalWebsites')) { |
||
| 55 | $values = []; |
||
| 56 | foreach ($data->{'AdditionalWebsites'} as $value) { |
||
| 57 | $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AdditionalWebsiteModel', 'json', $context); |
||
| 58 | } |
||
| 59 | $object->setAdditionalWebsites($values); |
||
| 60 | } |
||
| 61 | if (property_exists($data, 'BasicAuthenticationApiModel')) { |
||
| 62 | $object->setBasicAuthenticationApiModel($this->denormalizer->denormalize($data->{'BasicAuthenticationApiModel'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\BasicAuthenticationSettingModel', 'json', $context)); |
||
| 63 | } |
||
| 64 | if (property_exists($data, 'ClientCertificateAuthenticationSetting')) { |
||
| 65 | $object->setClientCertificateAuthenticationSetting($this->denormalizer->denormalize($data->{'ClientCertificateAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ClientCertificateAuthenticationApiModel', 'json', $context)); |
||
| 66 | } |
||
| 67 | if (property_exists($data, 'Cookies')) { |
||
| 68 | $object->setCookies($data->{'Cookies'}); |
||
| 69 | } |
||
| 70 | if (property_exists($data, 'CrawlAndAttack')) { |
||
| 71 | $object->setCrawlAndAttack($data->{'CrawlAndAttack'}); |
||
| 72 | } |
||
| 73 | if (property_exists($data, 'EnableHeuristicChecksInCustomUrlRewrite')) { |
||
| 74 | $object->setEnableHeuristicChecksInCustomUrlRewrite($data->{'EnableHeuristicChecksInCustomUrlRewrite'}); |
||
| 75 | } |
||
| 76 | if (property_exists($data, 'ExcludedLinks')) { |
||
| 77 | $values_1 = []; |
||
| 78 | foreach ($data->{'ExcludedLinks'} as $value_1) { |
||
| 79 | $values_1[] = $this->denormalizer->denormalize($value_1, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ExcludedLinkModel', 'json', $context); |
||
| 80 | } |
||
| 81 | $object->setExcludedLinks($values_1); |
||
| 82 | } |
||
| 83 | if (property_exists($data, 'DisallowedHttpMethods')) { |
||
| 84 | $values_2 = []; |
||
| 85 | foreach ($data->{'DisallowedHttpMethods'} as $value_2) { |
||
| 86 | $values_2[] = $value_2; |
||
| 87 | } |
||
| 88 | $object->setDisallowedHttpMethods($values_2); |
||
| 89 | } |
||
| 90 | if (property_exists($data, 'ExcludeLinks')) { |
||
| 91 | $object->setExcludeLinks($data->{'ExcludeLinks'}); |
||
| 92 | } |
||
| 93 | if (property_exists($data, 'FindAndFollowNewLinks')) { |
||
| 94 | $object->setFindAndFollowNewLinks($data->{'FindAndFollowNewLinks'}); |
||
| 95 | } |
||
| 96 | if (property_exists($data, 'FormAuthenticationSettingModel')) { |
||
| 97 | $object->setFormAuthenticationSettingModel($this->denormalizer->denormalize($data->{'FormAuthenticationSettingModel'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\FormAuthenticationSettingModel', 'json', $context)); |
||
| 98 | } |
||
| 99 | if (property_exists($data, 'HeaderAuthentication')) { |
||
| 100 | $object->setHeaderAuthentication($this->denormalizer->denormalize($data->{'HeaderAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\HeaderAuthenticationModel', 'json', $context)); |
||
| 101 | } |
||
| 102 | if (property_exists($data, 'ImportedLinks')) { |
||
| 103 | $values_3 = []; |
||
| 104 | foreach ($data->{'ImportedLinks'} as $value_3) { |
||
| 105 | $values_3[] = $value_3; |
||
| 106 | } |
||
| 107 | $object->setImportedLinks($values_3); |
||
| 108 | } |
||
| 109 | if (property_exists($data, 'ImportedFiles')) { |
||
| 110 | $values_4 = []; |
||
| 111 | foreach ($data->{'ImportedFiles'} as $value_4) { |
||
| 112 | $values_4[] = $this->denormalizer->denormalize($value_4, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ApiFileModel', 'json', $context); |
||
| 113 | } |
||
| 114 | $object->setImportedFiles($values_4); |
||
| 115 | } |
||
| 116 | if (property_exists($data, 'IsMaxScanDurationEnabled')) { |
||
| 117 | $object->setIsMaxScanDurationEnabled($data->{'IsMaxScanDurationEnabled'}); |
||
| 118 | } |
||
| 119 | if (property_exists($data, 'MaxDynamicSignatures')) { |
||
| 120 | $object->setMaxDynamicSignatures($data->{'MaxDynamicSignatures'}); |
||
| 121 | } |
||
| 122 | if (property_exists($data, 'MaxScanDuration')) { |
||
| 123 | $object->setMaxScanDuration($data->{'MaxScanDuration'}); |
||
| 124 | } |
||
| 125 | if (property_exists($data, 'PolicyId')) { |
||
| 126 | $object->setPolicyId($data->{'PolicyId'}); |
||
| 127 | } |
||
| 128 | if (property_exists($data, 'ReportPolicyId')) { |
||
| 129 | $object->setReportPolicyId($data->{'ReportPolicyId'}); |
||
| 130 | } |
||
| 131 | if (property_exists($data, 'Scope')) { |
||
| 132 | $object->setScope($data->{'Scope'}); |
||
| 133 | } |
||
| 134 | if (property_exists($data, 'SubPathMaxDynamicSignatures')) { |
||
| 135 | $object->setSubPathMaxDynamicSignatures($data->{'SubPathMaxDynamicSignatures'}); |
||
| 136 | } |
||
| 137 | if (property_exists($data, 'TimeWindow')) { |
||
| 138 | $object->setTimeWindow($this->denormalizer->denormalize($data->{'TimeWindow'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScanTimeWindowModel', 'json', $context)); |
||
| 139 | } |
||
| 140 | if (property_exists($data, 'UrlRewriteAnalyzableExtensions')) { |
||
| 141 | $object->setUrlRewriteAnalyzableExtensions($data->{'UrlRewriteAnalyzableExtensions'}); |
||
| 142 | } |
||
| 143 | if (property_exists($data, 'UrlRewriteBlockSeparators')) { |
||
| 144 | $object->setUrlRewriteBlockSeparators($data->{'UrlRewriteBlockSeparators'}); |
||
| 145 | } |
||
| 146 | if (property_exists($data, 'UrlRewriteMode')) { |
||
| 147 | $object->setUrlRewriteMode($data->{'UrlRewriteMode'}); |
||
| 148 | } |
||
| 149 | if (property_exists($data, 'UrlRewriteRules')) { |
||
| 150 | $values_5 = []; |
||
| 151 | foreach ($data->{'UrlRewriteRules'} as $value_5) { |
||
| 152 | $values_5[] = $this->denormalizer->denormalize($value_5, 'Montross50\\NetsparkerCloud\\SDK\\Model\\UrlRewriteRuleModel', 'json', $context); |
||
| 153 | } |
||
| 154 | $object->setUrlRewriteRules($values_5); |
||
| 155 | } |
||
| 156 | |||
| 157 | return $object; |
||
| 158 | } |
||
| 159 | |||
| 160 | public function normalize($object, $format = null, array $context = []) |
||
| 279 | } |
||
| 280 | } |
||
| 281 |