Conditions | 69 |
Total Lines | 211 |
Code Lines | 140 |
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 |
||
252 | public function normalize($object, $format = null, array $context = []) |
||
253 | { |
||
254 | $data = new \stdClass(); |
||
255 | if (null !== $object->getAdditionalWebsites()) { |
||
256 | $values = []; |
||
257 | foreach ($object->getAdditionalWebsites() as $value) { |
||
258 | $values[] = $this->normalizer->normalize($value, 'json', $context); |
||
259 | } |
||
260 | $data->{'AdditionalWebsites'} = $values; |
||
261 | } |
||
262 | if (null !== $object->getAgentId()) { |
||
263 | $data->{'AgentId'} = $object->getAgentId(); |
||
264 | } |
||
265 | if (null !== $object->getAgentName()) { |
||
266 | $data->{'AgentName'} = $object->getAgentName(); |
||
267 | } |
||
268 | if (null !== $object->getCookies()) { |
||
269 | $data->{'Cookies'} = $object->getCookies(); |
||
270 | } |
||
271 | if (null !== $object->getCrawlAndAttack()) { |
||
272 | $data->{'CrawlAndAttack'} = $object->getCrawlAndAttack(); |
||
273 | } |
||
274 | if (null !== $object->getEnableHeuristicChecksInCustomUrlRewrite()) { |
||
275 | $data->{'EnableHeuristicChecksInCustomUrlRewrite'} = $object->getEnableHeuristicChecksInCustomUrlRewrite(); |
||
276 | } |
||
277 | if (null !== $object->getExcludedLinks()) { |
||
278 | $data->{'ExcludedLinks'} = $object->getExcludedLinks(); |
||
279 | } |
||
280 | if (null !== $object->getExcludeLinks()) { |
||
281 | $data->{'ExcludeLinks'} = $object->getExcludeLinks(); |
||
282 | } |
||
283 | if (null !== $object->getDisallowedHttpMethods()) { |
||
284 | $data->{'DisallowedHttpMethods'} = $object->getDisallowedHttpMethods(); |
||
285 | } |
||
286 | if (null !== $object->getFindAndFollowNewLinks()) { |
||
287 | $data->{'FindAndFollowNewLinks'} = $object->getFindAndFollowNewLinks(); |
||
288 | } |
||
289 | if (null !== $object->getImportedLinks()) { |
||
290 | $data->{'ImportedLinks'} = $object->getImportedLinks(); |
||
291 | } |
||
292 | if (null !== $object->getDesktopScanId()) { |
||
293 | $data->{'DesktopScanId'} = $object->getDesktopScanId(); |
||
294 | } |
||
295 | if (null !== $object->getInitiated()) { |
||
296 | $data->{'Initiated'} = $object->getInitiated(); |
||
297 | } |
||
298 | if (null !== $object->getInitiatedDate()) { |
||
299 | $data->{'InitiatedDate'} = $object->getInitiatedDate(); |
||
300 | } |
||
301 | if (null !== $object->getInitiatedAt()) { |
||
302 | $data->{'InitiatedAt'} = $object->getInitiatedAt()->format("Y-m-d\TH:i:sP"); |
||
303 | } |
||
304 | if (null !== $object->getMaxDynamicSignatures()) { |
||
305 | $data->{'MaxDynamicSignatures'} = $object->getMaxDynamicSignatures(); |
||
306 | } |
||
307 | if (null !== $object->getMaxScanDuration()) { |
||
308 | $data->{'MaxScanDuration'} = $object->getMaxScanDuration(); |
||
309 | } |
||
310 | if (null !== $object->getPolicyDescription()) { |
||
311 | $data->{'PolicyDescription'} = $object->getPolicyDescription(); |
||
312 | } |
||
313 | if (null !== $object->getPolicyId()) { |
||
314 | $data->{'PolicyId'} = $object->getPolicyId(); |
||
315 | } |
||
316 | if (null !== $object->getPolicyName()) { |
||
317 | $data->{'PolicyName'} = $object->getPolicyName(); |
||
318 | } |
||
319 | if (null !== $object->getReportPolicyDescription()) { |
||
320 | $data->{'ReportPolicyDescription'} = $object->getReportPolicyDescription(); |
||
321 | } |
||
322 | if (null !== $object->getReportPolicyId()) { |
||
323 | $data->{'ReportPolicyId'} = $object->getReportPolicyId(); |
||
324 | } |
||
325 | if (null !== $object->getReportPolicyName()) { |
||
326 | $data->{'ReportPolicyName'} = $object->getReportPolicyName(); |
||
327 | } |
||
328 | if (null !== $object->getScope()) { |
||
329 | $data->{'Scope'} = $object->getScope(); |
||
330 | } |
||
331 | if (null !== $object->getSubPathMaxDynamicSignatures()) { |
||
332 | $data->{'SubPathMaxDynamicSignatures'} = $object->getSubPathMaxDynamicSignatures(); |
||
333 | } |
||
334 | if (null !== $object->getTargetPath()) { |
||
335 | $data->{'TargetPath'} = $object->getTargetPath(); |
||
336 | } |
||
337 | if (null !== $object->getTargetUrl()) { |
||
338 | $data->{'TargetUrl'} = $object->getTargetUrl(); |
||
339 | } |
||
340 | if (null !== $object->getTargetUrlRoot()) { |
||
341 | $data->{'TargetUrlRoot'} = $object->getTargetUrlRoot(); |
||
342 | } |
||
343 | if (null !== $object->getTimeWindow()) { |
||
344 | $data->{'TimeWindow'} = $this->normalizer->normalize($object->getTimeWindow(), 'json', $context); |
||
345 | } |
||
346 | if (null !== $object->getTotalVulnerabilityCount()) { |
||
347 | $data->{'TotalVulnerabilityCount'} = $object->getTotalVulnerabilityCount(); |
||
348 | } |
||
349 | if (null !== $object->getUrlRewriteAnalyzableExtensions()) { |
||
350 | $data->{'UrlRewriteAnalyzableExtensions'} = $object->getUrlRewriteAnalyzableExtensions(); |
||
351 | } |
||
352 | if (null !== $object->getUrlRewriteBlockSeparators()) { |
||
353 | $data->{'UrlRewriteBlockSeparators'} = $object->getUrlRewriteBlockSeparators(); |
||
354 | } |
||
355 | if (null !== $object->getUrlRewriteMode()) { |
||
356 | $data->{'UrlRewriteMode'} = $object->getUrlRewriteMode(); |
||
357 | } |
||
358 | if (null !== $object->getUrlRewriteRules()) { |
||
359 | $values_1 = []; |
||
360 | foreach ($object->getUrlRewriteRules() as $value_1) { |
||
361 | $values_1[] = $this->normalizer->normalize($value_1, 'json', $context); |
||
362 | } |
||
363 | $data->{'UrlRewriteRules'} = $values_1; |
||
364 | } |
||
365 | if (null !== $object->getUserId()) { |
||
366 | $data->{'UserId'} = $object->getUserId(); |
||
367 | } |
||
368 | if (null !== $object->getVcsCommitInfo()) { |
||
369 | $data->{'VcsCommitInfo'} = $this->normalizer->normalize($object->getVcsCommitInfo(), 'json', $context); |
||
370 | } |
||
371 | if (null !== $object->getWebsiteName()) { |
||
372 | $data->{'WebsiteName'} = $object->getWebsiteName(); |
||
373 | } |
||
374 | if (null !== $object->getWebsiteUrl()) { |
||
375 | $data->{'WebsiteUrl'} = $object->getWebsiteUrl(); |
||
376 | } |
||
377 | if (null !== $object->getCompletedSteps()) { |
||
378 | $data->{'CompletedSteps'} = $object->getCompletedSteps(); |
||
379 | } |
||
380 | if (null !== $object->getEstimatedLaunchTime()) { |
||
381 | $data->{'EstimatedLaunchTime'} = $object->getEstimatedLaunchTime(); |
||
382 | } |
||
383 | if (null !== $object->getEstimatedSteps()) { |
||
384 | $data->{'EstimatedSteps'} = $object->getEstimatedSteps(); |
||
385 | } |
||
386 | if (null !== $object->getFailureReason()) { |
||
387 | $data->{'FailureReason'} = $object->getFailureReason(); |
||
388 | } |
||
389 | if (null !== $object->getFailureReasonDescription()) { |
||
390 | $data->{'FailureReasonDescription'} = $object->getFailureReasonDescription(); |
||
391 | } |
||
392 | if (null !== $object->getFailureReasonString()) { |
||
393 | $data->{'FailureReasonString'} = $object->getFailureReasonString(); |
||
394 | } |
||
395 | if (null !== $object->getGlobalThreatLevel()) { |
||
396 | $data->{'GlobalThreatLevel'} = $object->getGlobalThreatLevel(); |
||
397 | } |
||
398 | if (null !== $object->getGlobalVulnerabilityCriticalCount()) { |
||
399 | $data->{'GlobalVulnerabilityCriticalCount'} = $object->getGlobalVulnerabilityCriticalCount(); |
||
400 | } |
||
401 | if (null !== $object->getGlobalVulnerabilityHighCount()) { |
||
402 | $data->{'GlobalVulnerabilityHighCount'} = $object->getGlobalVulnerabilityHighCount(); |
||
403 | } |
||
404 | if (null !== $object->getGlobalVulnerabilityInfoCount()) { |
||
405 | $data->{'GlobalVulnerabilityInfoCount'} = $object->getGlobalVulnerabilityInfoCount(); |
||
406 | } |
||
407 | if (null !== $object->getGlobalVulnerabilityLowCount()) { |
||
408 | $data->{'GlobalVulnerabilityLowCount'} = $object->getGlobalVulnerabilityLowCount(); |
||
409 | } |
||
410 | if (null !== $object->getGlobalVulnerabilityMediumCount()) { |
||
411 | $data->{'GlobalVulnerabilityMediumCount'} = $object->getGlobalVulnerabilityMediumCount(); |
||
412 | } |
||
413 | if (null !== $object->getId()) { |
||
414 | $data->{'Id'} = $object->getId(); |
||
415 | } |
||
416 | if (null !== $object->getIsCompleted()) { |
||
417 | $data->{'IsCompleted'} = $object->getIsCompleted(); |
||
418 | } |
||
419 | if (null !== $object->getPercentage()) { |
||
420 | $data->{'Percentage'} = $object->getPercentage(); |
||
421 | } |
||
422 | if (null !== $object->getPhase()) { |
||
423 | $data->{'Phase'} = $object->getPhase(); |
||
424 | } |
||
425 | if (null !== $object->getScanTaskGroupId()) { |
||
426 | $data->{'ScanTaskGroupId'} = $object->getScanTaskGroupId(); |
||
427 | } |
||
428 | if (null !== $object->getScanType()) { |
||
429 | $data->{'ScanType'} = $object->getScanType(); |
||
430 | } |
||
431 | if (null !== $object->getScheduledScanId()) { |
||
432 | $data->{'ScheduledScanId'} = $object->getScheduledScanId(); |
||
433 | } |
||
434 | if (null !== $object->getState()) { |
||
435 | $data->{'State'} = $object->getState(); |
||
436 | } |
||
437 | if (null !== $object->getStateChanged()) { |
||
438 | $data->{'StateChanged'} = $object->getStateChanged()->format("Y-m-d\TH:i:sP"); |
||
439 | } |
||
440 | if (null !== $object->getThreatLevel()) { |
||
441 | $data->{'ThreatLevel'} = $object->getThreatLevel(); |
||
442 | } |
||
443 | if (null !== $object->getVulnerabilityCriticalCount()) { |
||
444 | $data->{'VulnerabilityCriticalCount'} = $object->getVulnerabilityCriticalCount(); |
||
445 | } |
||
446 | if (null !== $object->getVulnerabilityHighCount()) { |
||
447 | $data->{'VulnerabilityHighCount'} = $object->getVulnerabilityHighCount(); |
||
448 | } |
||
449 | if (null !== $object->getVulnerabilityInfoCount()) { |
||
450 | $data->{'VulnerabilityInfoCount'} = $object->getVulnerabilityInfoCount(); |
||
451 | } |
||
452 | if (null !== $object->getVulnerabilityLowCount()) { |
||
453 | $data->{'VulnerabilityLowCount'} = $object->getVulnerabilityLowCount(); |
||
454 | } |
||
455 | if (null !== $object->getVulnerabilityMediumCount()) { |
||
456 | $data->{'VulnerabilityMediumCount'} = $object->getVulnerabilityMediumCount(); |
||
457 | } |
||
458 | if (null !== $object->getWebsiteId()) { |
||
459 | $data->{'WebsiteId'} = $object->getWebsiteId(); |
||
460 | } |
||
461 | |||
462 | return $data; |
||
463 | } |
||
465 |