| Conditions | 12 |
| Paths | 1 |
| Total Lines | 71 |
| Lines | 34 |
| Ratio | 47.89 % |
| 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 |
||
| 18 | public function transformEnums(): Closure |
||
| 19 | { |
||
| 20 | return function (array $transformations) { |
||
| 21 | if (isset($transformations[EnumRequest::REQUEST_ROUTE])) { |
||
| 22 | $route = $this->route(); |
||
|
|
|||
| 23 | |||
| 24 | foreach ($transformations[EnumRequest::REQUEST_ROUTE] as $key => $enumClass) { |
||
| 25 | if (! $route->hasParameter($key)) { |
||
| 26 | continue; |
||
| 27 | } |
||
| 28 | |||
| 29 | $route->setParameter( |
||
| 30 | $key, |
||
| 31 | forward_static_call( |
||
| 32 | $enumClass.'::make', |
||
| 33 | $route->parameter($key) |
||
| 34 | ) |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | unset($transformations[EnumRequest::REQUEST_ROUTE]); |
||
| 39 | } |
||
| 40 | |||
| 41 | View Code Duplication | if (isset($transformations[EnumRequest::REQUEST_QUERY])) { |
|
| 42 | foreach ($transformations[EnumRequest::REQUEST_QUERY] as $key => $enumClass) { |
||
| 43 | if (! $this->query->has($key)) { |
||
| 44 | continue; |
||
| 45 | } |
||
| 46 | |||
| 47 | $this->query->set( |
||
| 48 | $key, |
||
| 49 | forward_static_call( |
||
| 50 | $enumClass.'::make', |
||
| 51 | $this->query->get($key) |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | unset($transformations[EnumRequest::REQUEST_QUERY]); |
||
| 57 | } |
||
| 58 | |||
| 59 | View Code Duplication | if (isset($transformations[EnumRequest::REQUEST_REQUEST])) { |
|
| 60 | foreach ($transformations[EnumRequest::REQUEST_REQUEST] as $key => $enumClass) { |
||
| 61 | if (! $this->request->has($key)) { |
||
| 62 | continue; |
||
| 63 | } |
||
| 64 | |||
| 65 | $this->request->set( |
||
| 66 | $key, |
||
| 67 | forward_static_call( |
||
| 68 | $enumClass.'::make', |
||
| 69 | $this->request->get($key) |
||
| 70 | ) |
||
| 71 | ); |
||
| 72 | } |
||
| 73 | |||
| 74 | unset($transformations[EnumRequest::REQUEST_REQUEST]); |
||
| 75 | } |
||
| 76 | |||
| 77 | foreach ($transformations as $key => $enumClass) { |
||
| 78 | if (! isset($this[$key])) { |
||
| 79 | continue; |
||
| 80 | } |
||
| 81 | |||
| 82 | $this[$key] = forward_static_call( |
||
| 83 | $enumClass.'::make', |
||
| 84 | $this[$key] |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | }; |
||
| 88 | } |
||
| 89 | } |
||
| 90 |
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.