| Conditions | 11 |
| Paths | 11 |
| Total Lines | 26 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 23 |
| CRAP Score | 11 |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 8 | 11 | private function getValueFromUrlPlaceholder($name, UriInterface $uri) |
|
| 9 | { |
||
| 10 | switch ($name) { |
||
| 11 | 11 | case 'full': |
|
| 12 | 11 | case null: |
|
| 13 | 2 | return $uri->__toString(); |
|
| 14 | 9 | case 'host': |
|
| 15 | 1 | return $uri->getHost(); |
|
| 16 | 8 | case 'scheme': |
|
| 17 | 1 | return $uri->getScheme(); |
|
| 18 | 7 | case 'authority': |
|
| 19 | 1 | return $uri->getAuthority(); |
|
| 20 | 6 | case 'fragment': |
|
| 21 | 1 | return $uri->getFragment(); |
|
| 22 | 5 | case 'path': |
|
| 23 | 1 | return $uri->getPath(); |
|
| 24 | 4 | case 'port': |
|
| 25 | 1 | return $uri->getPort(); |
|
| 26 | 3 | case 'query': |
|
| 27 | 1 | return $uri->getQuery(); |
|
| 28 | 2 | case 'user-info': |
|
| 29 | 1 | return $uri->getUserInfo(); |
|
| 30 | 1 | default: |
|
| 31 | 1 | throw new \Exception('Invalid config'); |
|
| 32 | 1 | } |
|
| 33 | } |
||
| 34 | } |
||
| 35 |