Conditions | 10 |
Paths | 17 |
Total Lines | 33 |
Lines | 0 |
Ratio | 0 % |
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 |
||
58 | protected function getRouteInformation($route) |
||
59 | { |
||
60 | if (!is_a($route, 'Illuminate\Routing\Route')) { |
||
61 | return []; |
||
62 | } |
||
63 | $uri = head($route->methods()) . ' ' . $route->uri(); |
||
64 | $action = $route->getAction(); |
||
65 | |||
66 | $result = [ |
||
67 | 'uri' => $uri ?: '-', |
||
68 | ]; |
||
69 | |||
70 | $result = array_merge($result, $action); |
||
71 | |||
72 | |||
73 | if (isset($action['controller']) && strpos($action['controller'], '@') !== false) { |
||
74 | list($controller, $method) = explode('@', $action['controller']); |
||
75 | if(class_exists($controller) && method_exists($controller, $method)) { |
||
76 | $reflector = new \ReflectionMethod($controller, $method); |
||
77 | } |
||
78 | unset($result['uses']); |
||
79 | } elseif (isset($action['uses']) && $action['uses'] instanceof \Closure) { |
||
80 | $reflector = new \ReflectionFunction($action['uses']); |
||
81 | $result['uses'] = $result['uses']; |
||
82 | } |
||
83 | |||
84 | if (isset($reflector)) { |
||
85 | $filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/'); |
||
86 | $result['file'] = $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine(); |
||
87 | } |
||
88 | |||
89 | return $result; |
||
90 | } |
||
91 | |||
118 | } |