| Total Complexity | 91 |
| Total Lines | 290 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like UpdateScheduledScanModelNormalizer 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 UpdateScheduledScanModelNormalizer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class UpdateScheduledScanModelNormalizer 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\\UpdateScheduledScanModel'; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function supportsNormalization($data, $format = null) |
||
| 32 | { |
||
| 33 | return $data instanceof \Montross50\NetsparkerCloud\SDK\Model\UpdateScheduledScanModel; |
||
| 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\UpdateScheduledScanModel(); |
||
| 42 | if (property_exists($data, 'Id')) { |
||
| 43 | $object->setId($data->{'Id'}); |
||
| 44 | } |
||
| 45 | if (property_exists($data, 'OccurencesCount')) { |
||
| 46 | $object->setOccurencesCount($data->{'OccurencesCount'}); |
||
| 47 | } |
||
| 48 | if (property_exists($data, 'Disabled')) { |
||
| 49 | $object->setDisabled($data->{'Disabled'}); |
||
| 50 | } |
||
| 51 | if (property_exists($data, 'EnableScheduling')) { |
||
| 52 | $object->setEnableScheduling($data->{'EnableScheduling'}); |
||
| 53 | } |
||
| 54 | if (property_exists($data, 'Name')) { |
||
| 55 | $object->setName($data->{'Name'}); |
||
| 56 | } |
||
| 57 | if (property_exists($data, 'NextExecutionTime')) { |
||
| 58 | $object->setNextExecutionTime($data->{'NextExecutionTime'}); |
||
| 59 | } |
||
| 60 | if (property_exists($data, 'ScanGroupId')) { |
||
| 61 | $object->setScanGroupId($data->{'ScanGroupId'}); |
||
| 62 | } |
||
| 63 | if (property_exists($data, 'ScanType')) { |
||
| 64 | $object->setScanType($data->{'ScanType'}); |
||
| 65 | } |
||
| 66 | if (property_exists($data, 'ScheduleRunType')) { |
||
| 67 | $object->setScheduleRunType($data->{'ScheduleRunType'}); |
||
| 68 | } |
||
| 69 | if (property_exists($data, 'CustomRecurrence')) { |
||
| 70 | $object->setCustomRecurrence($this->denormalizer->denormalize($data->{'CustomRecurrence'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScheduledScanRecurrenceViewModel', 'json', $context)); |
||
| 71 | } |
||
| 72 | if (property_exists($data, 'IsTargetUrlRequired')) { |
||
| 73 | $object->setIsTargetUrlRequired($data->{'IsTargetUrlRequired'}); |
||
| 74 | } |
||
| 75 | if (property_exists($data, 'AdditionalWebsites')) { |
||
| 76 | $object->setAdditionalWebsites($this->denormalizer->denormalize($data->{'AdditionalWebsites'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AdditionalWebsitesSettingModel', 'json', $context)); |
||
| 77 | } |
||
| 78 | if (property_exists($data, 'AgentGroupId')) { |
||
| 79 | $object->setAgentGroupId($data->{'AgentGroupId'}); |
||
| 80 | } |
||
| 81 | if (property_exists($data, 'AgentId')) { |
||
| 82 | $object->setAgentId($data->{'AgentId'}); |
||
| 83 | } |
||
| 84 | if (property_exists($data, 'BasicAuthenticationSetting')) { |
||
| 85 | $object->setBasicAuthenticationSetting($this->denormalizer->denormalize($data->{'BasicAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\BasicAuthenticationSettingModel', 'json', $context)); |
||
| 86 | } |
||
| 87 | if (property_exists($data, 'CanEdit')) { |
||
| 88 | $object->setCanEdit($data->{'CanEdit'}); |
||
| 89 | } |
||
| 90 | if (property_exists($data, 'ClientCertificateAuthentication')) { |
||
| 91 | $object->setClientCertificateAuthentication($this->denormalizer->denormalize($data->{'ClientCertificateAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ClientCertificateAuthenticationViewModel', 'json', $context)); |
||
| 92 | } |
||
| 93 | if (property_exists($data, 'Cookies')) { |
||
| 94 | $object->setCookies($data->{'Cookies'}); |
||
| 95 | } |
||
| 96 | if (property_exists($data, 'CrawlAndAttack')) { |
||
| 97 | $object->setCrawlAndAttack($data->{'CrawlAndAttack'}); |
||
| 98 | } |
||
| 99 | if (property_exists($data, 'CreateType')) { |
||
| 100 | $object->setCreateType($data->{'CreateType'}); |
||
| 101 | } |
||
| 102 | if (property_exists($data, 'FindAndFollowNewLinks')) { |
||
| 103 | $object->setFindAndFollowNewLinks($data->{'FindAndFollowNewLinks'}); |
||
| 104 | } |
||
| 105 | if (property_exists($data, 'FormAuthenticationSetting')) { |
||
| 106 | $object->setFormAuthenticationSetting($this->denormalizer->denormalize($data->{'FormAuthenticationSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\FormAuthenticationSettingModel', 'json', $context)); |
||
| 107 | } |
||
| 108 | if (property_exists($data, 'HeaderAuthentication')) { |
||
| 109 | $object->setHeaderAuthentication($this->denormalizer->denormalize($data->{'HeaderAuthentication'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\HeaderAuthenticationModel', 'json', $context)); |
||
| 110 | } |
||
| 111 | if (property_exists($data, 'ImportedLinks')) { |
||
| 112 | $object->setImportedLinks($this->denormalizer->denormalize($data->{'ImportedLinks'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ImportedLinksSetting', 'json', $context)); |
||
| 113 | } |
||
| 114 | if (property_exists($data, 'IsMaxScanDurationEnabled')) { |
||
| 115 | $object->setIsMaxScanDurationEnabled($data->{'IsMaxScanDurationEnabled'}); |
||
| 116 | } |
||
| 117 | if (property_exists($data, 'IsPrimary')) { |
||
| 118 | $object->setIsPrimary($data->{'IsPrimary'}); |
||
| 119 | } |
||
| 120 | if (property_exists($data, 'IsShared')) { |
||
| 121 | $object->setIsShared($data->{'IsShared'}); |
||
| 122 | } |
||
| 123 | if (property_exists($data, 'MaxScanDuration')) { |
||
| 124 | $object->setMaxScanDuration($data->{'MaxScanDuration'}); |
||
| 125 | } |
||
| 126 | if (property_exists($data, 'PolicyId')) { |
||
| 127 | $object->setPolicyId($data->{'PolicyId'}); |
||
| 128 | } |
||
| 129 | if (property_exists($data, 'ProfileId')) { |
||
| 130 | $object->setProfileId($data->{'ProfileId'}); |
||
| 131 | } |
||
| 132 | if (property_exists($data, 'ProfileName')) { |
||
| 133 | $object->setProfileName($data->{'ProfileName'}); |
||
| 134 | } |
||
| 135 | if (property_exists($data, 'ReportPolicyId')) { |
||
| 136 | $object->setReportPolicyId($data->{'ReportPolicyId'}); |
||
| 137 | } |
||
| 138 | if (property_exists($data, 'SaveScanProfile')) { |
||
| 139 | $object->setSaveScanProfile($data->{'SaveScanProfile'}); |
||
| 140 | } |
||
| 141 | if (property_exists($data, 'ScopeSetting')) { |
||
| 142 | $object->setScopeSetting($this->denormalizer->denormalize($data->{'ScopeSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScopeSetting', 'json', $context)); |
||
| 143 | } |
||
| 144 | if (property_exists($data, 'SelectedAgents')) { |
||
| 145 | $values = []; |
||
| 146 | foreach ($data->{'SelectedAgents'} as $value) { |
||
| 147 | $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AgentSelectionModel', 'json', $context); |
||
| 148 | } |
||
| 149 | $object->setSelectedAgents($values); |
||
| 150 | } |
||
| 151 | if (property_exists($data, 'SelectedScanProfileId')) { |
||
| 152 | $object->setSelectedScanProfileId($data->{'SelectedScanProfileId'}); |
||
| 153 | } |
||
| 154 | if (property_exists($data, 'SelectedScanProfileName')) { |
||
| 155 | $object->setSelectedScanProfileName($data->{'SelectedScanProfileName'}); |
||
| 156 | } |
||
| 157 | if (property_exists($data, 'TargetUrl')) { |
||
| 158 | $object->setTargetUrl($data->{'TargetUrl'}); |
||
| 159 | } |
||
| 160 | if (property_exists($data, 'TimeWindow')) { |
||
| 161 | $object->setTimeWindow($this->denormalizer->denormalize($data->{'TimeWindow'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScanTimeWindowViewModel', 'json', $context)); |
||
| 162 | } |
||
| 163 | if (property_exists($data, 'UrlRewriteSetting')) { |
||
| 164 | $object->setUrlRewriteSetting($this->denormalizer->denormalize($data->{'UrlRewriteSetting'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\UrlRewriteSetting', 'json', $context)); |
||
| 165 | } |
||
| 166 | if (property_exists($data, 'UserId')) { |
||
| 167 | $object->setUserId($data->{'UserId'}); |
||
| 168 | } |
||
| 169 | if (property_exists($data, 'WebsiteGroupId')) { |
||
| 170 | $object->setWebsiteGroupId($data->{'WebsiteGroupId'}); |
||
| 171 | } |
||
| 172 | |||
| 173 | return $object; |
||
| 174 | } |
||
| 175 | |||
| 176 | public function normalize($object, $format = null, array $context = []) |
||
| 311 | } |
||
| 312 | } |
||
| 313 |