| Conditions | 16 |
| Paths | 16384 |
| Total Lines | 51 |
| Code Lines | 33 |
| 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 |
||
| 92 | public function normalize($object, $format = null, array $context = []) |
||
| 93 | { |
||
| 94 | $data = new \stdClass(); |
||
| 95 | if (null !== $object->getAccept()) { |
||
| 96 | $data->{'Accept'} = $object->getAccept(); |
||
| 97 | } |
||
| 98 | if (null !== $object->getAcceptCharset()) { |
||
| 99 | $data->{'AcceptCharset'} = $object->getAcceptCharset(); |
||
| 100 | } |
||
| 101 | if (null !== $object->getAcceptLanguage()) { |
||
| 102 | $data->{'AcceptLanguage'} = $object->getAcceptLanguage(); |
||
| 103 | } |
||
| 104 | if (null !== $object->getEnableCookies()) { |
||
| 105 | $data->{'EnableCookies'} = $object->getEnableCookies(); |
||
| 106 | } |
||
| 107 | if (null !== $object->getEnableGzipAndDeflate()) { |
||
| 108 | $data->{'EnableGzipAndDeflate'} = $object->getEnableGzipAndDeflate(); |
||
| 109 | } |
||
| 110 | if (null !== $object->getHttpKeepAlive()) { |
||
| 111 | $data->{'HttpKeepAlive'} = $object->getHttpKeepAlive(); |
||
| 112 | } |
||
| 113 | if (null !== $object->getLogHttpRequests()) { |
||
| 114 | $data->{'LogHttpRequests'} = $object->getLogHttpRequests(); |
||
| 115 | } |
||
| 116 | if (null !== $object->getRequestLimiterRequestPerUnitTime()) { |
||
| 117 | $data->{'RequestLimiterRequestPerUnitTime'} = $object->getRequestLimiterRequestPerUnitTime(); |
||
| 118 | } |
||
| 119 | if (null !== $object->getRequestLimiterUnitTime()) { |
||
| 120 | $data->{'RequestLimiterUnitTime'} = $object->getRequestLimiterUnitTime(); |
||
| 121 | } |
||
| 122 | if (null !== $object->getRequestTimeout()) { |
||
| 123 | $data->{'RequestTimeout'} = $object->getRequestTimeout(); |
||
| 124 | } |
||
| 125 | if (null !== $object->getThreadCount()) { |
||
| 126 | $data->{'ThreadCount'} = $object->getThreadCount(); |
||
| 127 | } |
||
| 128 | if (null !== $object->getUserAgent()) { |
||
| 129 | $data->{'UserAgent'} = $object->getUserAgent(); |
||
| 130 | } |
||
| 131 | if (null !== $object->getUserAgents()) { |
||
| 132 | $values = new \stdClass(); |
||
| 133 | foreach ($object->getUserAgents() as $key => $value) { |
||
| 134 | $values->{$key} = $value; |
||
| 135 | } |
||
| 136 | $data->{'UserAgents'} = $values; |
||
| 137 | } |
||
| 138 | if (null !== $object->getForceUserAgent()) { |
||
| 139 | $data->{'ForceUserAgent'} = $object->getForceUserAgent(); |
||
| 140 | } |
||
| 141 | |||
| 142 | return $data; |
||
| 143 | } |
||
| 145 |