| Conditions | 70 |
| Total Lines | 214 |
| Code Lines | 142 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 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\ScanTaskModel(); |
||
| 42 | if (property_exists($data, 'AdditionalWebsites')) { |
||
| 43 | $values = []; |
||
| 44 | foreach ($data->{'AdditionalWebsites'} as $value) { |
||
| 45 | $values[] = $this->denormalizer->denormalize($value, 'Montross50\\NetsparkerCloud\\SDK\\Model\\AdditionalWebsiteModel', 'json', $context); |
||
| 46 | } |
||
| 47 | $object->setAdditionalWebsites($values); |
||
| 48 | } |
||
| 49 | if (property_exists($data, 'AgentId')) { |
||
| 50 | $object->setAgentId($data->{'AgentId'}); |
||
| 51 | } |
||
| 52 | if (property_exists($data, 'AgentName')) { |
||
| 53 | $object->setAgentName($data->{'AgentName'}); |
||
| 54 | } |
||
| 55 | if (property_exists($data, 'Cookies')) { |
||
| 56 | $object->setCookies($data->{'Cookies'}); |
||
| 57 | } |
||
| 58 | if (property_exists($data, 'CrawlAndAttack')) { |
||
| 59 | $object->setCrawlAndAttack($data->{'CrawlAndAttack'}); |
||
| 60 | } |
||
| 61 | if (property_exists($data, 'EnableHeuristicChecksInCustomUrlRewrite')) { |
||
| 62 | $object->setEnableHeuristicChecksInCustomUrlRewrite($data->{'EnableHeuristicChecksInCustomUrlRewrite'}); |
||
| 63 | } |
||
| 64 | if (property_exists($data, 'ExcludedLinks')) { |
||
| 65 | $object->setExcludedLinks($data->{'ExcludedLinks'}); |
||
| 66 | } |
||
| 67 | if (property_exists($data, 'ExcludeLinks')) { |
||
| 68 | $object->setExcludeLinks($data->{'ExcludeLinks'}); |
||
| 69 | } |
||
| 70 | if (property_exists($data, 'DisallowedHttpMethods')) { |
||
| 71 | $object->setDisallowedHttpMethods($data->{'DisallowedHttpMethods'}); |
||
| 72 | } |
||
| 73 | if (property_exists($data, 'FindAndFollowNewLinks')) { |
||
| 74 | $object->setFindAndFollowNewLinks($data->{'FindAndFollowNewLinks'}); |
||
| 75 | } |
||
| 76 | if (property_exists($data, 'ImportedLinks')) { |
||
| 77 | $object->setImportedLinks($data->{'ImportedLinks'}); |
||
| 78 | } |
||
| 79 | if (property_exists($data, 'DesktopScanId')) { |
||
| 80 | $object->setDesktopScanId($data->{'DesktopScanId'}); |
||
| 81 | } |
||
| 82 | if (property_exists($data, 'Initiated')) { |
||
| 83 | $object->setInitiated($data->{'Initiated'}); |
||
| 84 | } |
||
| 85 | if (property_exists($data, 'InitiatedDate')) { |
||
| 86 | $object->setInitiatedDate($data->{'InitiatedDate'}); |
||
| 87 | } |
||
| 88 | if (property_exists($data, 'InitiatedAt')) { |
||
| 89 | $object->setInitiatedAt(\DateTime::createFromFormat("Y-m-d\TH:i:sP", $data->{'InitiatedAt'})); |
||
|
|
|||
| 90 | } |
||
| 91 | if (property_exists($data, 'MaxDynamicSignatures')) { |
||
| 92 | $object->setMaxDynamicSignatures($data->{'MaxDynamicSignatures'}); |
||
| 93 | } |
||
| 94 | if (property_exists($data, 'MaxScanDuration')) { |
||
| 95 | $object->setMaxScanDuration($data->{'MaxScanDuration'}); |
||
| 96 | } |
||
| 97 | if (property_exists($data, 'PolicyDescription')) { |
||
| 98 | $object->setPolicyDescription($data->{'PolicyDescription'}); |
||
| 99 | } |
||
| 100 | if (property_exists($data, 'PolicyId')) { |
||
| 101 | $object->setPolicyId($data->{'PolicyId'}); |
||
| 102 | } |
||
| 103 | if (property_exists($data, 'PolicyName')) { |
||
| 104 | $object->setPolicyName($data->{'PolicyName'}); |
||
| 105 | } |
||
| 106 | if (property_exists($data, 'ReportPolicyDescription')) { |
||
| 107 | $object->setReportPolicyDescription($data->{'ReportPolicyDescription'}); |
||
| 108 | } |
||
| 109 | if (property_exists($data, 'ReportPolicyId')) { |
||
| 110 | $object->setReportPolicyId($data->{'ReportPolicyId'}); |
||
| 111 | } |
||
| 112 | if (property_exists($data, 'ReportPolicyName')) { |
||
| 113 | $object->setReportPolicyName($data->{'ReportPolicyName'}); |
||
| 114 | } |
||
| 115 | if (property_exists($data, 'Scope')) { |
||
| 116 | $object->setScope($data->{'Scope'}); |
||
| 117 | } |
||
| 118 | if (property_exists($data, 'SubPathMaxDynamicSignatures')) { |
||
| 119 | $object->setSubPathMaxDynamicSignatures($data->{'SubPathMaxDynamicSignatures'}); |
||
| 120 | } |
||
| 121 | if (property_exists($data, 'TargetPath')) { |
||
| 122 | $object->setTargetPath($data->{'TargetPath'}); |
||
| 123 | } |
||
| 124 | if (property_exists($data, 'TargetUrl')) { |
||
| 125 | $object->setTargetUrl($data->{'TargetUrl'}); |
||
| 126 | } |
||
| 127 | if (property_exists($data, 'TargetUrlRoot')) { |
||
| 128 | $object->setTargetUrlRoot($data->{'TargetUrlRoot'}); |
||
| 129 | } |
||
| 130 | if (property_exists($data, 'TimeWindow')) { |
||
| 131 | $object->setTimeWindow($this->denormalizer->denormalize($data->{'TimeWindow'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\ScanTimeWindowModel', 'json', $context)); |
||
| 132 | } |
||
| 133 | if (property_exists($data, 'TotalVulnerabilityCount')) { |
||
| 134 | $object->setTotalVulnerabilityCount($data->{'TotalVulnerabilityCount'}); |
||
| 135 | } |
||
| 136 | if (property_exists($data, 'UrlRewriteAnalyzableExtensions')) { |
||
| 137 | $object->setUrlRewriteAnalyzableExtensions($data->{'UrlRewriteAnalyzableExtensions'}); |
||
| 138 | } |
||
| 139 | if (property_exists($data, 'UrlRewriteBlockSeparators')) { |
||
| 140 | $object->setUrlRewriteBlockSeparators($data->{'UrlRewriteBlockSeparators'}); |
||
| 141 | } |
||
| 142 | if (property_exists($data, 'UrlRewriteMode')) { |
||
| 143 | $object->setUrlRewriteMode($data->{'UrlRewriteMode'}); |
||
| 144 | } |
||
| 145 | if (property_exists($data, 'UrlRewriteRules')) { |
||
| 146 | $values_1 = []; |
||
| 147 | foreach ($data->{'UrlRewriteRules'} as $value_1) { |
||
| 148 | $values_1[] = $this->denormalizer->denormalize($value_1, 'Montross50\\NetsparkerCloud\\SDK\\Model\\UrlRewriteRuleModel', 'json', $context); |
||
| 149 | } |
||
| 150 | $object->setUrlRewriteRules($values_1); |
||
| 151 | } |
||
| 152 | if (property_exists($data, 'UserId')) { |
||
| 153 | $object->setUserId($data->{'UserId'}); |
||
| 154 | } |
||
| 155 | if (property_exists($data, 'VcsCommitInfo')) { |
||
| 156 | $object->setVcsCommitInfo($this->denormalizer->denormalize($data->{'VcsCommitInfo'}, 'Montross50\\NetsparkerCloud\\SDK\\Model\\VcsCommitInfo', 'json', $context)); |
||
| 157 | } |
||
| 158 | if (property_exists($data, 'WebsiteName')) { |
||
| 159 | $object->setWebsiteName($data->{'WebsiteName'}); |
||
| 160 | } |
||
| 161 | if (property_exists($data, 'WebsiteUrl')) { |
||
| 162 | $object->setWebsiteUrl($data->{'WebsiteUrl'}); |
||
| 163 | } |
||
| 164 | if (property_exists($data, 'CompletedSteps')) { |
||
| 165 | $object->setCompletedSteps($data->{'CompletedSteps'}); |
||
| 166 | } |
||
| 167 | if (property_exists($data, 'EstimatedLaunchTime')) { |
||
| 168 | $object->setEstimatedLaunchTime($data->{'EstimatedLaunchTime'}); |
||
| 169 | } |
||
| 170 | if (property_exists($data, 'EstimatedSteps')) { |
||
| 171 | $object->setEstimatedSteps($data->{'EstimatedSteps'}); |
||
| 172 | } |
||
| 173 | if (property_exists($data, 'FailureReason')) { |
||
| 174 | $object->setFailureReason($data->{'FailureReason'}); |
||
| 175 | } |
||
| 176 | if (property_exists($data, 'FailureReasonDescription')) { |
||
| 177 | $object->setFailureReasonDescription($data->{'FailureReasonDescription'}); |
||
| 178 | } |
||
| 179 | if (property_exists($data, 'FailureReasonString')) { |
||
| 180 | $object->setFailureReasonString($data->{'FailureReasonString'}); |
||
| 181 | } |
||
| 182 | if (property_exists($data, 'GlobalThreatLevel')) { |
||
| 183 | $object->setGlobalThreatLevel($data->{'GlobalThreatLevel'}); |
||
| 184 | } |
||
| 185 | if (property_exists($data, 'GlobalVulnerabilityCriticalCount')) { |
||
| 186 | $object->setGlobalVulnerabilityCriticalCount($data->{'GlobalVulnerabilityCriticalCount'}); |
||
| 187 | } |
||
| 188 | if (property_exists($data, 'GlobalVulnerabilityHighCount')) { |
||
| 189 | $object->setGlobalVulnerabilityHighCount($data->{'GlobalVulnerabilityHighCount'}); |
||
| 190 | } |
||
| 191 | if (property_exists($data, 'GlobalVulnerabilityInfoCount')) { |
||
| 192 | $object->setGlobalVulnerabilityInfoCount($data->{'GlobalVulnerabilityInfoCount'}); |
||
| 193 | } |
||
| 194 | if (property_exists($data, 'GlobalVulnerabilityLowCount')) { |
||
| 195 | $object->setGlobalVulnerabilityLowCount($data->{'GlobalVulnerabilityLowCount'}); |
||
| 196 | } |
||
| 197 | if (property_exists($data, 'GlobalVulnerabilityMediumCount')) { |
||
| 198 | $object->setGlobalVulnerabilityMediumCount($data->{'GlobalVulnerabilityMediumCount'}); |
||
| 199 | } |
||
| 200 | if (property_exists($data, 'Id')) { |
||
| 201 | $object->setId($data->{'Id'}); |
||
| 202 | } |
||
| 203 | if (property_exists($data, 'IsCompleted')) { |
||
| 204 | $object->setIsCompleted($data->{'IsCompleted'}); |
||
| 205 | } |
||
| 206 | if (property_exists($data, 'Percentage')) { |
||
| 207 | $object->setPercentage($data->{'Percentage'}); |
||
| 208 | } |
||
| 209 | if (property_exists($data, 'Phase')) { |
||
| 210 | $object->setPhase($data->{'Phase'}); |
||
| 211 | } |
||
| 212 | if (property_exists($data, 'ScanTaskGroupId')) { |
||
| 213 | $object->setScanTaskGroupId($data->{'ScanTaskGroupId'}); |
||
| 214 | } |
||
| 215 | if (property_exists($data, 'ScanType')) { |
||
| 216 | $object->setScanType($data->{'ScanType'}); |
||
| 217 | } |
||
| 218 | if (property_exists($data, 'ScheduledScanId')) { |
||
| 219 | $object->setScheduledScanId($data->{'ScheduledScanId'}); |
||
| 220 | } |
||
| 221 | if (property_exists($data, 'State')) { |
||
| 222 | $object->setState($data->{'State'}); |
||
| 223 | } |
||
| 224 | if (property_exists($data, 'StateChanged')) { |
||
| 225 | $object->setStateChanged(\DateTime::createFromFormat("Y-m-d\TH:i:sP", $data->{'StateChanged'})); |
||
| 226 | } |
||
| 227 | if (property_exists($data, 'ThreatLevel')) { |
||
| 228 | $object->setThreatLevel($data->{'ThreatLevel'}); |
||
| 229 | } |
||
| 230 | if (property_exists($data, 'VulnerabilityCriticalCount')) { |
||
| 231 | $object->setVulnerabilityCriticalCount($data->{'VulnerabilityCriticalCount'}); |
||
| 232 | } |
||
| 233 | if (property_exists($data, 'VulnerabilityHighCount')) { |
||
| 234 | $object->setVulnerabilityHighCount($data->{'VulnerabilityHighCount'}); |
||
| 235 | } |
||
| 236 | if (property_exists($data, 'VulnerabilityInfoCount')) { |
||
| 237 | $object->setVulnerabilityInfoCount($data->{'VulnerabilityInfoCount'}); |
||
| 238 | } |
||
| 239 | if (property_exists($data, 'VulnerabilityLowCount')) { |
||
| 240 | $object->setVulnerabilityLowCount($data->{'VulnerabilityLowCount'}); |
||
| 241 | } |
||
| 242 | if (property_exists($data, 'VulnerabilityMediumCount')) { |
||
| 243 | $object->setVulnerabilityMediumCount($data->{'VulnerabilityMediumCount'}); |
||
| 244 | } |
||
| 245 | if (property_exists($data, 'WebsiteId')) { |
||
| 246 | $object->setWebsiteId($data->{'WebsiteId'}); |
||
| 247 | } |
||
| 248 | |||
| 249 | return $object; |
||
| 250 | } |
||
| 465 |