| Total Complexity | 45 |
| Total Lines | 150 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like JavaScriptSettingsModelNormalizer 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 JavaScriptSettingsModelNormalizer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class JavaScriptSettingsModelNormalizer 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\\JavaScriptSettingsModel'; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function supportsNormalization($data, $format = null) |
||
| 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\JavaScriptSettingsModel(); |
||
| 42 | if (property_exists($data, 'BailThreshold')) { |
||
| 43 | $object->setBailThreshold($data->{'BailThreshold'}); |
||
| 44 | } |
||
| 45 | if (property_exists($data, 'ConfirmOpenRedirectSimulateTimeout')) { |
||
| 46 | $object->setConfirmOpenRedirectSimulateTimeout($data->{'ConfirmOpenRedirectSimulateTimeout'}); |
||
| 47 | } |
||
| 48 | if (property_exists($data, 'ConfirmXssSimulateTimeout')) { |
||
| 49 | $object->setConfirmXssSimulateTimeout($data->{'ConfirmXssSimulateTimeout'}); |
||
| 50 | } |
||
| 51 | if (property_exists($data, 'DomParserAllowOutOfScopeXmlHttpRequests')) { |
||
| 52 | $object->setDomParserAllowOutOfScopeXmlHttpRequests($data->{'DomParserAllowOutOfScopeXmlHttpRequests'}); |
||
| 53 | } |
||
| 54 | if (property_exists($data, 'DomParserDfsLimit')) { |
||
| 55 | $object->setDomParserDfsLimit($data->{'DomParserDfsLimit'}); |
||
| 56 | } |
||
| 57 | if (property_exists($data, 'DomParserDotify')) { |
||
| 58 | $object->setDomParserDotify($data->{'DomParserDotify'}); |
||
| 59 | } |
||
| 60 | if (property_exists($data, 'DomParserExclusionCssSelector')) { |
||
| 61 | $object->setDomParserExclusionCssSelector($data->{'DomParserExclusionCssSelector'}); |
||
| 62 | } |
||
| 63 | if (property_exists($data, 'DomParserExtractResources')) { |
||
| 64 | $object->setDomParserExtractResources($data->{'DomParserExtractResources'}); |
||
| 65 | } |
||
| 66 | if (property_exists($data, 'DomParserFilterColonEvents')) { |
||
| 67 | $object->setDomParserFilterColonEvents($data->{'DomParserFilterColonEvents'}); |
||
| 68 | } |
||
| 69 | if (property_exists($data, 'DomParserFilterDocumentEvents')) { |
||
| 70 | $object->setDomParserFilterDocumentEvents($data->{'DomParserFilterDocumentEvents'}); |
||
| 71 | } |
||
| 72 | if (property_exists($data, 'DomParserIgnoreDocumentEvents')) { |
||
| 73 | $object->setDomParserIgnoreDocumentEvents($data->{'DomParserIgnoreDocumentEvents'}); |
||
| 74 | } |
||
| 75 | if (property_exists($data, 'DomParserLoadUrlTimeout')) { |
||
| 76 | $object->setDomParserLoadUrlTimeout($data->{'DomParserLoadUrlTimeout'}); |
||
| 77 | } |
||
| 78 | if (property_exists($data, 'DomParserMaxOptionElementsPerSelect')) { |
||
| 79 | $object->setDomParserMaxOptionElementsPerSelect($data->{'DomParserMaxOptionElementsPerSelect'}); |
||
| 80 | } |
||
| 81 | if (property_exists($data, 'DomParserPersistentJavaScriptCookies')) { |
||
| 82 | $object->setDomParserPersistentJavaScriptCookies($data->{'DomParserPersistentJavaScriptCookies'}); |
||
| 83 | } |
||
| 84 | if (property_exists($data, 'DomParserPreSimulateWait')) { |
||
| 85 | $object->setDomParserPreSimulateWait($data->{'DomParserPreSimulateWait'}); |
||
| 86 | } |
||
| 87 | if (property_exists($data, 'DomParserSimulationTimeout')) { |
||
| 88 | $object->setDomParserSimulationTimeout($data->{'DomParserSimulationTimeout'}); |
||
| 89 | } |
||
| 90 | if (property_exists($data, 'EnableDomParser')) { |
||
| 91 | $object->setEnableDomParser($data->{'EnableDomParser'}); |
||
| 92 | } |
||
| 93 | if (property_exists($data, 'IntereventTimeout')) { |
||
| 94 | $object->setIntereventTimeout($data->{'IntereventTimeout'}); |
||
| 95 | } |
||
| 96 | if (property_exists($data, 'SkipElementCount')) { |
||
| 97 | $object->setSkipElementCount($data->{'SkipElementCount'}); |
||
| 98 | } |
||
| 99 | if (property_exists($data, 'SkipThreshold')) { |
||
| 100 | $object->setSkipThreshold($data->{'SkipThreshold'}); |
||
| 101 | } |
||
| 102 | |||
| 103 | return $object; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function normalize($object, $format = null, array $context = []) |
||
| 171 | } |
||
| 172 | } |
||
| 173 |