| Conditions | 10 |
| Paths | 96 |
| Total Lines | 30 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 3 |
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 |
||
| 17 | public function execute(array $arguments) |
||
| 18 | { |
||
| 19 | $actionName = (isset($arguments[0]) ? $arguments[0] : false); |
||
| 20 | $parameters = (isset($arguments[1]) ? $arguments[1] : array()); |
||
| 21 | $escapeAmp = (isset($arguments[2]) ? (bool)$arguments[2] : false); |
||
| 22 | $includeHostScheme = (isset($arguments[3]) ? (bool)$arguments[3] : false); |
||
| 23 | |||
| 24 | $baseUrl = $this->getViewHelperService() |
||
| 25 | ->getContext() |
||
| 26 | ->getRequest() |
||
| 27 | ->getBaseUrl(); |
||
| 28 | |||
| 29 | if (false === $actionName) { |
||
| 30 | return (empty($baseUrl) ? '/' : $baseUrl); |
||
| 31 | } |
||
| 32 | |||
| 33 | if (empty($actionName)) { |
||
| 34 | throw new Exception(sprintf('Empty action name')); |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!is_array($parameters)) { |
||
| 38 | throw new Exception(sprintf('Parameters should be an array')); |
||
| 39 | } |
||
| 40 | |||
| 41 | $hostScheme = $this->getViewHelperService()->getContext()->getRequest()->getSchemeAndHttpHost(); |
||
| 42 | |||
| 43 | return ($includeHostScheme ? $hostScheme : null) . rtrim($baseUrl, '/') |
||
| 44 | . $this->getRequestMatcher() |
||
| 45 | ->reverse($actionName, $parameters, $escapeAmp); |
||
| 46 | } |
||
| 47 | |||
| 59 | } |