| 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 |
||
| 70 | protected function doGetArguments(JsonRpcRequest $request, $controller, array $parameters) |
||
| 71 | { |
||
| 72 | $attributes = $request->attributes->all(); |
||
| 73 | $arguments = []; |
||
| 74 | |||
| 75 | foreach ($parameters as $param) { |
||
| 76 | |||
| 77 | if (array_key_exists($param->name, $attributes)) { |
||
| 78 | if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) { |
||
| 79 | $arguments = array_merge($arguments, array_values($attributes[$param->name])); |
||
| 80 | } else { |
||
| 81 | $arguments[] = $attributes[$param->name]; |
||
| 82 | } |
||
| 83 | } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { |
||
| 84 | $arguments[] = $request; |
||
| 85 | } elseif ($param->isDefaultValueAvailable()) { |
||
| 86 | $arguments[] = $param->getDefaultValue(); |
||
| 87 | } else { |
||
| 88 | if (is_array($controller)) { |
||
| 89 | $repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); |
||
| 90 | } elseif (is_object($controller)) { |
||
| 91 | $repr = get_class($controller); |
||
| 92 | } else { |
||
| 93 | $repr = $controller; |
||
| 94 | } |
||
| 95 | |||
| 96 | 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)); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | return $arguments; |
||
| 101 | } |
||
| 102 | |||
| 123 |
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.