Conditions | 3 |
Paths | 4 |
Total Lines | 52 |
Code Lines | 39 |
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 |
||
66 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
67 | { |
||
68 | $this->layout = 'layouts/administration'; |
||
69 | |||
70 | $earliest = DB::table('log')->min('log_time'); |
||
71 | $latest = DB::table('log')->max('log_time'); |
||
72 | |||
73 | $earliest = $earliest ? Carbon::make($earliest) : Carbon::now(); |
||
74 | $latest = $latest ? Carbon::make($latest) : Carbon::now(); |
||
75 | |||
76 | $earliest = $earliest->toDateString(); |
||
|
|||
77 | $latest = $latest->toDateString(); |
||
78 | |||
79 | $params = $request->getQueryParams(); |
||
80 | $action = $params['action'] ?? ''; |
||
81 | $from = $params['from'] ?? $earliest; |
||
82 | $to = $params['to'] ?? $latest; |
||
83 | $type = $params['type'] ?? ''; |
||
84 | $text = $params['text'] ?? ''; |
||
85 | $ip = $params['ip'] ?? ''; |
||
86 | $username = $params['username'] ?? ''; |
||
87 | $tree = $params['tree'] ?? ''; |
||
88 | |||
89 | $from = max($from, $earliest); |
||
90 | $to = min(max($from, $to), $latest); |
||
91 | |||
92 | $user_options = $this->user_service->all()->mapWithKeys(static function (User $user): array { |
||
93 | return [$user->userName() => $user->userName()]; |
||
94 | }); |
||
95 | $user_options = (new Collection(['' => '']))->merge($user_options); |
||
96 | |||
97 | $tree_options = $this->tree_service->all()->mapWithKeys(static function (Tree $tree): array { |
||
98 | return [$tree->name() => $tree->title()]; |
||
99 | }); |
||
100 | $tree_options = (new Collection(['' => '']))->merge($tree_options); |
||
101 | |||
102 | $title = I18N::translate('Website logs'); |
||
103 | |||
104 | return $this->viewResponse('admin/site-logs', [ |
||
105 | 'action' => $action, |
||
106 | 'earliest' => $earliest, |
||
107 | 'from' => $from, |
||
108 | 'tree' => $tree, |
||
109 | 'ip' => $ip, |
||
110 | 'latest' => $latest, |
||
111 | 'tree_options' => $tree_options, |
||
112 | 'title' => $title, |
||
113 | 'to' => $to, |
||
114 | 'text' => $text, |
||
115 | 'type' => $type, |
||
116 | 'username' => $username, |
||
117 | 'user_options' => $user_options, |
||
118 | ]); |
||
121 |
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.