Conditions | 8 |
Paths | 37 |
Total Lines | 63 |
Code Lines | 42 |
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 |
||
91 | 'AVG(firstByte) AS firstByte', |
||
92 | 'AVG(connect) AS connect', |
||
93 | 'AVG(dns) AS dns', |
||
94 | |||
95 | 'AVG(craftTotalMs) AS craftTotalMs', |
||
96 | 'AVG(craftDbMs) AS craftDbMs', |
||
97 | 'AVG(craftDbCnt) AS craftDbCnt', |
||
98 | 'AVG(craftTwigMs) AS craftTwigMs', |
||
99 | 'AVG(craftTwigCnt) AS craftTwigCnt', |
||
100 | 'AVG(craftOtherMs) AS craftOtherMs', |
||
101 | 'AVG(craftOtherCnt) AS craftOtherCnt', |
||
102 | 'AVG(craftTotalMemory) AS craftTotalMemory', |
||
103 | ]) |
||
104 | ->from(['{{%webperf_data_samples}}']) |
||
105 | ->where(['between', 'dateCreated', $start, $end]) |
||
106 | ; |
||
107 | if (!empty($pageUrl)) { |
||
108 | $query->andWhere(['url' => $pageUrl]); |
||
109 | } |
||
110 | if ((int)$siteId !== 0) { |
||
111 | $query->andWhere(['siteId' => $siteId]); |
||
112 | } |
||
113 | $stats = $query->all(); |
||
114 | if ($stats) { |
||
115 | $data = $stats[0]; |
||
116 | } |
||
117 | |||
118 | return $data; |
||
119 | } |
||
120 | } |
||
121 |