@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ]) |
| 80 | 80 | ->where(['between', 'dateUpdated', $start, $end]) |
| 81 | 81 | ->andWhere(['not', [$column => null]]); |
| 82 | - if ((int)$siteId !== 0) { |
|
| 82 | + if ((int) $siteId !== 0) { |
|
| 83 | 83 | $query->andWhere(['siteId' => $siteId]); |
| 84 | 84 | } |
| 85 | 85 | if ($pageUrl !== '') { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ]) |
| 97 | 97 | ->where(['between', 'dateUpdated', $start, $end]) |
| 98 | 98 | ->andWhere(['not', [$column => null]]); |
| 99 | - if ((int)$siteId !== 0) { |
|
| 99 | + if ((int) $siteId !== 0) { |
|
| 100 | 100 | $query->andWhere(['siteId' => $siteId]); |
| 101 | 101 | } |
| 102 | 102 | $stats = $query->all(); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | // Massage the data |
| 105 | 105 | if ($stats) { |
| 106 | 106 | foreach ($stats as &$stat) { |
| 107 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 107 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 108 | 108 | } |
| 109 | 109 | $data = $stats[0]; |
| 110 | 110 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | ]) |
| 151 | 151 | ->where(['between', 'dateUpdated', $start, $end]) |
| 152 | 152 | ->andWhere(['not', [$column => null]]); |
| 153 | - if ((int)$siteId !== 0) { |
|
| 153 | + if ((int) $siteId !== 0) { |
|
| 154 | 154 | $query->andWhere(['siteId' => $siteId]); |
| 155 | 155 | } |
| 156 | 156 | $query |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | ]) |
| 172 | 172 | ->where(['between', 'dateUpdated', $start, $end]) |
| 173 | 173 | ->andWhere(['not', [$column => null]]); |
| 174 | - if ((int)$siteId !== 0) { |
|
| 174 | + if ((int) $siteId !== 0) { |
|
| 175 | 175 | $query->andWhere(['siteId' => $siteId]); |
| 176 | 176 | } |
| 177 | 177 | $query |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | // Massage the data |
| 184 | 184 | if ($stats) { |
| 185 | 185 | foreach ($stats as &$stat) { |
| 186 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 186 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 187 | 187 | $stat['detailPageUrl'] = UrlHelper::cpUrl('webperf/page-detail', [ |
| 188 | 188 | 'pageUrl' => $stat['url'], |
| 189 | 189 | 'siteId' => $siteId, |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | ]) |
| 241 | 241 | ->where(['between', 'dateUpdated', $start, $end]) |
| 242 | 242 | ; |
| 243 | - if ((int)$siteId !== 0) { |
|
| 243 | + if ((int) $siteId !== 0) { |
|
| 244 | 244 | $query->andWhere(['siteId' => $siteId]); |
| 245 | 245 | } |
| 246 | 246 | if ($pageUrl !== '') { |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | if ($userAgent) { |
| 162 | 162 | $parser = new Parser($userAgent); |
| 163 | 163 | $sample->device = $parser->device->model; |
| 164 | - $sample->browser = $parser->browser->name . ' ' . $parser->browser->getVersion(); |
|
| 165 | - $sample->os = $parser->os->name . ' ' . $parser->os->getVersion(); |
|
| 164 | + $sample->browser = $parser->browser->name.' '.$parser->browser->getVersion(); |
|
| 165 | + $sample->os = $parser->os->name.' '.$parser->os->getVersion(); |
|
| 166 | 166 | $sample->mobile = $parser->isMobile(); |
| 167 | 167 | } |
| 168 | 168 | // Save the data sample |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $now = round(microtime(true) * 1000); |
| 188 | 188 | $cache = Craft::$app->getCache(); |
| 189 | 189 | $then = $cache->get(self::LAST_BEACON_CACHE_KEY); |
| 190 | - if (($then !== false) && ($now - (int)$then < Webperf::$settings->rateLimitMs)) { |
|
| 190 | + if (($then !== false) && ($now - (int) $then < Webperf::$settings->rateLimitMs)) { |
|
| 191 | 191 | $limited = true; |
| 192 | 192 | Craft::warning('Beacon ignored due to rate limiting', __METHOD__); |
| 193 | 193 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ->offset($offset) |
| 104 | 104 | ->where(['between', 'dateUpdated', $start, $end]) |
| 105 | 105 | ; |
| 106 | - if ((int)$siteId !== 0) { |
|
| 106 | + if ((int) $siteId !== 0) { |
|
| 107 | 107 | $query->andWhere(['siteId' => $siteId]); |
| 108 | 108 | } |
| 109 | 109 | if ($filter !== '') { |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | $index = 1; |
| 143 | 143 | foreach ($stats as &$stat) { |
| 144 | 144 | $stat['id'] = $index++; |
| 145 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 146 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 145 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 146 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 147 | 147 | // Decode any emojis in the title |
| 148 | 148 | if (!empty($stat['title'])) { |
| 149 | 149 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | ->where(['url' => $pageUrl]) |
| 241 | 241 | ->andWhere(['between', 'dateUpdated', $start, $end]) |
| 242 | 242 | ; |
| 243 | - if ((int)$siteId !== 0) { |
|
| 243 | + if ((int) $siteId !== 0) { |
|
| 244 | 244 | $query->andWhere(['siteId' => $siteId]); |
| 245 | 245 | } |
| 246 | 246 | if ($filter !== '') { |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | $stat['type'] = 'frontend'; |
| 273 | 273 | } |
| 274 | 274 | if ($stat['pageLoad'] > $maxTotalPageLoad) { |
| 275 | - $maxTotalPageLoad = (int)$stat['pageLoad']; |
|
| 275 | + $maxTotalPageLoad = (int) $stat['pageLoad']; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | // Massage the stats |
| 279 | 279 | foreach ($stats as &$stat) { |
| 280 | - $stat['mobile'] = (bool)$stat['mobile']; |
|
| 281 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 280 | + $stat['mobile'] = (bool) $stat['mobile']; |
|
| 281 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 282 | 282 | // Decode any emojis in the title |
| 283 | 283 | if (!empty($stat['title'])) { |
| 284 | 284 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | $stats = Webperf::$plugin->profileTarget->stats; |
| 154 | 154 | $request = Craft::$app->getRequest(); |
| 155 | - $pageLoad = (int)($stats['database']['duration'] |
|
| 155 | + $pageLoad = (int) ($stats['database']['duration'] |
|
| 156 | 156 | + $stats['twig']['duration'] |
| 157 | 157 | + $stats['other']['duration']); |
| 158 | 158 | // Allocate a new DataSample, and fill it in |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | 'queryString' => $request->getQueryString(), |
| 163 | 163 | 'pageLoad' => $pageLoad, |
| 164 | 164 | 'craftTotalMs' => $pageLoad, |
| 165 | - 'craftDbMs' => (int)$stats['database']['duration'], |
|
| 166 | - 'craftDbCnt' => (int)$stats['database']['count'], |
|
| 167 | - 'craftTwigMs' => (int)$stats['twig']['duration'], |
|
| 168 | - 'craftTwigCnt' => (int)$stats['twig']['count'], |
|
| 169 | - 'craftOtherMs' => (int)$stats['other']['duration'], |
|
| 170 | - 'craftOtherCnt' => (int)$stats['other']['count'], |
|
| 171 | - 'craftTotalMemory' => (int)($stats['database']['memory'] |
|
| 165 | + 'craftDbMs' => (int) $stats['database']['duration'], |
|
| 166 | + 'craftDbCnt' => (int) $stats['database']['count'], |
|
| 167 | + 'craftTwigMs' => (int) $stats['twig']['duration'], |
|
| 168 | + 'craftTwigCnt' => (int) $stats['twig']['count'], |
|
| 169 | + 'craftOtherMs' => (int) $stats['other']['duration'], |
|
| 170 | + 'craftOtherCnt' => (int) $stats['other']['count'], |
|
| 171 | + 'craftTotalMemory' => (int) ($stats['database']['memory'] |
|
| 172 | 172 | + $stats['twig']['memory'] |
| 173 | 173 | + $stats['other']['memory']), |
| 174 | 174 | ]); |
@@ -92,8 +92,8 @@ |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | $this->stats[$cat]['count']++; |
| 95 | - $this->stats[$cat]['duration'] += (float)$timing['duration'] * 1000; |
|
| 96 | - $this->stats[$cat]['memory'] += (int)$timing['memoryDiff']; |
|
| 95 | + $this->stats[$cat]['duration'] += (float) $timing['duration'] * 1000; |
|
| 96 | + $this->stats[$cat]['memory'] += (int) $timing['memoryDiff']; |
|
| 97 | 97 | } |
| 98 | 98 | $this->stats['memory'] = memory_get_peak_usage(true); |
| 99 | 99 | if ($final) { |