| Conditions | 11 |
| Paths | 8 |
| Total Lines | 32 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 82 | protected function doGetArguments(RpcRequest $request, $controller, array $parameters) |
||
| 83 | { |
||
| 84 | $attributes = $request->attributes->all(); |
||
| 85 | $arguments = []; |
||
| 86 | |||
| 87 | foreach ($parameters as $param) { |
||
| 88 | |||
| 89 | if (array_key_exists($param->name, $attributes)) { |
||
| 90 | if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) { |
||
| 91 | $arguments = array_merge($arguments, array_values($attributes[$param->name])); |
||
| 92 | } else { |
||
| 93 | $arguments[] = $attributes[$param->name]; |
||
| 94 | } |
||
| 95 | } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { |
||
| 96 | $arguments[] = $request; |
||
| 97 | } elseif ($param->isDefaultValueAvailable()) { |
||
| 98 | $arguments[] = $param->getDefaultValue(); |
||
| 99 | } else { |
||
| 100 | if (is_array($controller)) { |
||
| 101 | $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); |
||
| 102 | } elseif (is_object($controller)) { |
||
| 103 | $repr = get_class($controller); |
||
| 104 | } else { |
||
| 105 | $repr = $controller; |
||
| 106 | } |
||
| 107 | |||
| 108 | throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name)); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | return $arguments; |
||
| 113 | } |
||
| 114 | |||
| 141 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.