Conditions | 18 |
Paths | 60 |
Total Lines | 135 |
Code Lines | 91 |
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 | string $end = '', |
||
59 | $siteId = 0 |
||
60 | ): Response { |
||
61 | PermissionHelper::controllerPermissionCheck('webperf:recommendations'); |
||
62 | $data = []; |
||
63 | $stats = Webperf::$plugin->recommendations->data($pageUrl, $start, $end, $siteId); |
||
64 | if (!empty($stats)) { |
||
65 | $recSample = new RecommendationDataSample($stats); |
||
66 | $data = Webperf::$plugin->recommendations->list($recSample); |
||
67 | } |
||
68 | |||
69 | return $this->asJson($data); |
||
70 | } |
||
71 | |||
72 | // Protected Methods |
||
73 | // ========================================================================= |
||
74 | } |
||
75 |