| Conditions | 17 |
| Paths | 16385 |
| Total Lines | 54 |
| Code Lines | 35 |
| 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\HttpRequestSettingModel(); |
||
| 42 | if (property_exists($data, 'Accept')) { |
||
| 43 | $object->setAccept($data->{'Accept'}); |
||
| 44 | } |
||
| 45 | if (property_exists($data, 'AcceptCharset')) { |
||
| 46 | $object->setAcceptCharset($data->{'AcceptCharset'}); |
||
| 47 | } |
||
| 48 | if (property_exists($data, 'AcceptLanguage')) { |
||
| 49 | $object->setAcceptLanguage($data->{'AcceptLanguage'}); |
||
| 50 | } |
||
| 51 | if (property_exists($data, 'EnableCookies')) { |
||
| 52 | $object->setEnableCookies($data->{'EnableCookies'}); |
||
| 53 | } |
||
| 54 | if (property_exists($data, 'EnableGzipAndDeflate')) { |
||
| 55 | $object->setEnableGzipAndDeflate($data->{'EnableGzipAndDeflate'}); |
||
| 56 | } |
||
| 57 | if (property_exists($data, 'HttpKeepAlive')) { |
||
| 58 | $object->setHttpKeepAlive($data->{'HttpKeepAlive'}); |
||
| 59 | } |
||
| 60 | if (property_exists($data, 'LogHttpRequests')) { |
||
| 61 | $object->setLogHttpRequests($data->{'LogHttpRequests'}); |
||
| 62 | } |
||
| 63 | if (property_exists($data, 'RequestLimiterRequestPerUnitTime')) { |
||
| 64 | $object->setRequestLimiterRequestPerUnitTime($data->{'RequestLimiterRequestPerUnitTime'}); |
||
| 65 | } |
||
| 66 | if (property_exists($data, 'RequestLimiterUnitTime')) { |
||
| 67 | $object->setRequestLimiterUnitTime($data->{'RequestLimiterUnitTime'}); |
||
| 68 | } |
||
| 69 | if (property_exists($data, 'RequestTimeout')) { |
||
| 70 | $object->setRequestTimeout($data->{'RequestTimeout'}); |
||
| 71 | } |
||
| 72 | if (property_exists($data, 'ThreadCount')) { |
||
| 73 | $object->setThreadCount($data->{'ThreadCount'}); |
||
| 74 | } |
||
| 75 | if (property_exists($data, 'UserAgent')) { |
||
| 76 | $object->setUserAgent($data->{'UserAgent'}); |
||
| 77 | } |
||
| 78 | if (property_exists($data, 'UserAgents')) { |
||
| 79 | $values = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS); |
||
| 80 | foreach ($data->{'UserAgents'} as $key => $value) { |
||
| 81 | $values[$key] = $value; |
||
| 82 | } |
||
| 83 | $object->setUserAgents($values); |
||
| 84 | } |
||
| 85 | if (property_exists($data, 'ForceUserAgent')) { |
||
| 86 | $object->setForceUserAgent($data->{'ForceUserAgent'}); |
||
| 87 | } |
||
| 88 | |||
| 89 | return $object; |
||
| 90 | } |
||
| 145 |