@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ->from(['{{%webperf_data_samples}}']) |
| 49 | 49 | ->where(['not', [$column => null]]) |
| 50 | 50 | ; |
| 51 | - if ((int)$siteId !== 0) { |
|
| 51 | + if ((int) $siteId !== 0) { |
|
| 52 | 52 | $query->andWhere(['siteId' => $siteId]); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ['not', ['title' => '']], |
| 75 | 75 | ]) |
| 76 | 76 | ; |
| 77 | - if ((int)$siteId !== 0) { |
|
| 77 | + if ((int) $siteId !== 0) { |
|
| 78 | 78 | $query->andWhere(['siteId' => $siteId]); |
| 79 | 79 | } |
| 80 | 80 | $result = $query->one(); |
@@ -45,6 +45,6 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function displayMs(int $number): string |
| 47 | 47 | { |
| 48 | - return number_format((float)$number / 1000, 2).'s'; |
|
| 48 | + return number_format((float) $number / 1000, 2).'s'; |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | ]) |
| 82 | 82 | ->where(['between', 'dateCreated', $start, $end]) |
| 83 | 83 | ->andWhere(['not', [$column => null]]); |
| 84 | - if ((int)$siteId !== 0) { |
|
| 84 | + if ((int) $siteId !== 0) { |
|
| 85 | 85 | $query->andWhere(['siteId' => $siteId]); |
| 86 | 86 | } |
| 87 | 87 | if ($pageUrl !== '') { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // Massage the data |
| 92 | 92 | if ($stats) { |
| 93 | 93 | foreach ($stats as &$stat) { |
| 94 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 94 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 95 | 95 | } |
| 96 | 96 | $data = $stats[0]; |
| 97 | 97 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ]) |
| 137 | 137 | ->where(['between', 'dateCreated', $start, $end]) |
| 138 | 138 | ->andWhere(['not', [$column => null]]); |
| 139 | - if ((int)$siteId !== 0) { |
|
| 139 | + if ((int) $siteId !== 0) { |
|
| 140 | 140 | $query->andWhere(['siteId' => $siteId]); |
| 141 | 141 | } |
| 142 | 142 | $query |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | // Massage the data |
| 148 | 148 | if ($stats) { |
| 149 | 149 | foreach ($stats as &$stat) { |
| 150 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 150 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 151 | 151 | $stat['detailPageUrl'] = UrlHelper::cpUrl('webperf/performance/page-detail', [ |
| 152 | 152 | 'pageUrl' => $stat['url'], |
| 153 | 153 | 'siteId' => $siteId, |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ]) |
| 219 | 219 | ->where(['between', 'dateCreated', $start, $end]) |
| 220 | 220 | ; |
| 221 | - if ((int)$siteId !== 0) { |
|
| 221 | + if ((int) $siteId !== 0) { |
|
| 222 | 222 | $query->andWhere(['siteId' => $siteId]); |
| 223 | 223 | } |
| 224 | 224 | if ($pageUrl !== '') { |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | ]) |
| 348 | 348 | ->where(['between', 'dateCreated', $start, $end]) |
| 349 | 349 | ; |
| 350 | - if ((int)$siteId !== 0) { |
|
| 350 | + if ((int) $siteId !== 0) { |
|
| 351 | 351 | $query->andWhere(['siteId' => $siteId]); |
| 352 | 352 | } |
| 353 | 353 | if ($pageUrl !== '') { |
@@ -391,11 +391,11 @@ discard block |
||
| 391 | 391 | $craftErrors['labels'][$index] = $stat['sampleDate']; |
| 392 | 392 | switch ($stat['type']) { |
| 393 | 393 | case 'boomerang': |
| 394 | - $boomerangErrors['data'][$index] = (int)$stat['cnt']; |
|
| 394 | + $boomerangErrors['data'][$index] = (int) $stat['cnt']; |
|
| 395 | 395 | $boomerangErrors['labels'][$index] = $stat['sampleDate']; |
| 396 | 396 | break; |
| 397 | 397 | case 'craft': |
| 398 | - $craftErrors['data'][$index] = (int)$stat['cnt']; |
|
| 398 | + $craftErrors['data'][$index] = (int) $stat['cnt']; |
|
| 399 | 399 | $craftErrors['labels'][$index] = $stat['sampleDate']; |
| 400 | 400 | break; |
| 401 | 401 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ->offset($offset) |
| 105 | 105 | ->where(['between', 'dateCreated', $start, $end]) |
| 106 | 106 | ; |
| 107 | - if ((int)$siteId !== 0) { |
|
| 107 | + if ((int) $siteId !== 0) { |
|
| 108 | 108 | $query->andWhere(['siteId' => $siteId]); |
| 109 | 109 | } |
| 110 | 110 | if ($filter !== '') { |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | $index = 1; |
| 144 | 144 | foreach ($stats as &$stat) { |
| 145 | 145 | $stat['id'] = $index++; |
| 146 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 147 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 146 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 147 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 148 | 148 | // Decode any emojis in the title |
| 149 | 149 | if (!empty($stat['title'])) { |
| 150 | 150 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ->where(['url' => $pageUrl]) |
| 243 | 243 | ->andWhere(['between', 'dateCreated', $start, $end]) |
| 244 | 244 | ; |
| 245 | - if ((int)$siteId !== 0) { |
|
| 245 | + if ((int) $siteId !== 0) { |
|
| 246 | 246 | $query->andWhere(['siteId' => $siteId]); |
| 247 | 247 | } |
| 248 | 248 | if ($filter !== '') { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $stat['type'] = 'frontend'; |
| 275 | 275 | } |
| 276 | 276 | if ($stat['pageLoad'] > $maxTotalPageLoad) { |
| 277 | - $maxTotalPageLoad = (int)$stat['pageLoad']; |
|
| 277 | + $maxTotalPageLoad = (int) $stat['pageLoad']; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | // Massage the stats |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | $date = DateTimeHelper::toDateTime($stats['dateCreated']); |
| 284 | 284 | $stats['dateCreated'] = $date->format('Y-m-d H:i:s'); |
| 285 | 285 | } |
| 286 | - $stat['mobile'] = (bool)$stat['mobile']; |
|
| 287 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 286 | + $stat['mobile'] = (bool) $stat['mobile']; |
|
| 287 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 288 | 288 | // Decode any emojis in the title |
| 289 | 289 | if (!empty($stat['title'])) { |
| 290 | 290 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | 'SUM(case when [[type]] = \'boomerang\' then 1 else 0 end) as [[boomerangCount]]', |
| 397 | 397 | ]); |
| 398 | 398 | } |
| 399 | - if ((int)$siteId !== 0) { |
|
| 399 | + if ((int) $siteId !== 0) { |
|
| 400 | 400 | $query->andWhere(['siteId' => $siteId]); |
| 401 | 401 | } |
| 402 | 402 | if ($filter !== '') { |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | $user = Craft::$app->getUser()->getIdentity(); |
| 418 | 418 | // Massage the stats |
| 419 | 419 | foreach ($stats as &$stat) { |
| 420 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 421 | - $stat['craftCount'] = (int)$stat['craftCount']; |
|
| 422 | - $stat['boomerangCount'] = (int)$stat['boomerangCount']; |
|
| 420 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 421 | + $stat['craftCount'] = (int) $stat['craftCount']; |
|
| 422 | + $stat['boomerangCount'] = (int) $stat['boomerangCount']; |
|
| 423 | 423 | // Decode any emojis in the title |
| 424 | 424 | if (!empty($stat['title'])) { |
| 425 | 425 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | ->andWhere(['between', '[[webperf_error_samples.dateCreated]]', $start, $end]) |
| 537 | 537 | ->leftJoin('{{%webperf_data_samples}} webperf_data_samples', '[[webperf_data_samples.requestId]] = [[webperf_error_samples.requestId]]') |
| 538 | 538 | ; |
| 539 | - if ((int)$siteId !== 0) { |
|
| 539 | + if ((int) $siteId !== 0) { |
|
| 540 | 540 | $query->andWhere(['siteId' => $siteId]); |
| 541 | 541 | } |
| 542 | 542 | if ($filter !== '') { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | $stats['dateCreated'] = $date->format('Y-m-d H:i:s'); |
| 565 | 565 | } |
| 566 | 566 | if (isset($stat['mobile'])) { |
| 567 | - $stat['mobile'] = (bool)$stat['mobile']; |
|
| 567 | + $stat['mobile'] = (bool) $stat['mobile']; |
|
| 568 | 568 | } |
| 569 | 569 | // Decode any emojis in the title |
| 570 | 570 | if (!empty($stat['title'])) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ->from(['{{%webperf_error_samples}}']) |
| 83 | 83 | ->where(['not', [$column => null]]) |
| 84 | 84 | ; |
| 85 | - if ((int)$siteId !== 0) { |
|
| 85 | + if ((int) $siteId !== 0) { |
|
| 86 | 86 | $query->andWhere(['siteId' => $siteId]); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | ->andWhere(['type' => $type]) |
| 115 | 115 | ; |
| 116 | 116 | } |
| 117 | - if ((int)$siteId !== 0) { |
|
| 117 | + if ((int) $siteId !== 0) { |
|
| 118 | 118 | $query->andWhere(['siteId' => $siteId]); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ['not', ['title' => '']], |
| 141 | 141 | ]) |
| 142 | 142 | ; |
| 143 | - if ((int)$siteId !== 0) { |
|
| 143 | + if ((int) $siteId !== 0) { |
|
| 144 | 144 | $query->andWhere(['siteId' => $siteId]); |
| 145 | 145 | } |
| 146 | 146 | $result = $query->one(); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | Event::on( |
| 304 | 304 | Plugins::class, |
| 305 | 305 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 306 | - function (PluginEvent $event) { |
|
| 306 | + function(PluginEvent $event) { |
|
| 307 | 307 | if ($event->plugin === $this) { |
| 308 | 308 | // Invalidate our caches after we've been installed |
| 309 | 309 | $this->clearAllCaches(); |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | Event::on( |
| 332 | 332 | CraftVariable::class, |
| 333 | 333 | CraftVariable::EVENT_INIT, |
| 334 | - function (Event $event) { |
|
| 334 | + function(Event $event) { |
|
| 335 | 335 | /** @var CraftVariable $variable */ |
| 336 | 336 | $variable = $event->sender; |
| 337 | 337 | $variable->set('webperf', WebperfVariable::class); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | Event::on( |
| 342 | 342 | Plugins::class, |
| 343 | 343 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 344 | - function () { |
|
| 344 | + function() { |
|
| 345 | 345 | // Install these only after all other plugins have loaded |
| 346 | 346 | $request = Craft::$app->getRequest(); |
| 347 | 347 | // Only respond to non-console site requests |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | Event::on( |
| 366 | 366 | UrlManager::class, |
| 367 | 367 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 368 | - function (RegisterUrlRulesEvent $event) { |
|
| 368 | + function(RegisterUrlRulesEvent $event) { |
|
| 369 | 369 | Craft::debug( |
| 370 | 370 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 371 | 371 | __METHOD__ |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | Event::on( |
| 389 | 389 | UrlManager::class, |
| 390 | 390 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 391 | - function (RegisterUrlRulesEvent $event) { |
|
| 391 | + function(RegisterUrlRulesEvent $event) { |
|
| 392 | 392 | Craft::debug( |
| 393 | 393 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 394 | 394 | __METHOD__ |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | Event::on( |
| 405 | 405 | Dashboard::class, |
| 406 | 406 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
| 407 | - function (RegisterComponentTypesEvent $event) { |
|
| 407 | + function(RegisterComponentTypesEvent $event) { |
|
| 408 | 408 | $event->types[] = MetricsWidget::class; |
| 409 | 409 | } |
| 410 | 410 | ); |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | Event::on( |
| 413 | 413 | UserPermissions::class, |
| 414 | 414 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 415 | - function (RegisterUserPermissionsEvent $event) { |
|
| 415 | + function(RegisterUserPermissionsEvent $event) { |
|
| 416 | 416 | Craft::debug( |
| 417 | 417 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 418 | 418 | __METHOD__ |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | Event::on( |
| 438 | 438 | View::class, |
| 439 | 439 | View::EVENT_END_PAGE, |
| 440 | - function () { |
|
| 440 | + function() { |
|
| 441 | 441 | Craft::debug( |
| 442 | 442 | 'View::EVENT_END_PAGE', |
| 443 | 443 | __METHOD__ |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | Event::on( |
| 462 | 462 | View::class, |
| 463 | 463 | View::EVENT_END_BODY, |
| 464 | - function () { |
|
| 464 | + function() { |
|
| 465 | 465 | Craft::debug( |
| 466 | 466 | 'View::EVENT_END_BODY', |
| 467 | 467 | __METHOD__ |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | Event::on( |
| 485 | 485 | Application::class, |
| 486 | 486 | Application::EVENT_AFTER_REQUEST, |
| 487 | - function () { |
|
| 487 | + function() { |
|
| 488 | 488 | Craft::debug( |
| 489 | 489 | 'Application::EVENT_AFTER_REQUEST', |
| 490 | 490 | __METHOD__ |
@@ -510,21 +510,21 @@ discard block |
||
| 510 | 510 | if (self::$settings->displaySidebar && $currentUser && $currentUser->can('webperf:sidebar')) { |
| 511 | 511 | $view = Craft::$app->getView(); |
| 512 | 512 | // Entries sidebar |
| 513 | - $view->hook('cp.entries.edit.details', function (&$context) { |
|
| 513 | + $view->hook('cp.entries.edit.details', function(&$context) { |
|
| 514 | 514 | /** @var Element $element */ |
| 515 | 515 | $element = $context['entry'] ?? null; |
| 516 | 516 | |
| 517 | 517 | return $this->renderSidebar($element); |
| 518 | 518 | }); |
| 519 | 519 | // Category Groups sidebar |
| 520 | - $view->hook('cp.categories.edit.details', function (&$context) { |
|
| 520 | + $view->hook('cp.categories.edit.details', function(&$context) { |
|
| 521 | 521 | /** @var Element $element */ |
| 522 | 522 | $element = $context['category'] ?? null; |
| 523 | 523 | |
| 524 | 524 | return $this->renderSidebar($element); |
| 525 | 525 | }); |
| 526 | 526 | // Commerce Product Types sidebar |
| 527 | - $view->hook('cp.commerce.product.edit.details', function (&$context) { |
|
| 527 | + $view->hook('cp.commerce.product.edit.details', function(&$context) { |
|
| 528 | 528 | /** @var Element $element */ |
| 529 | 529 | $element = $context['product'] ?? null; |
| 530 | 530 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | { |
| 732 | 732 | $cache = Craft::$app->getCache(); |
| 733 | 733 | // See if there are any recommendations to add as a badge |
| 734 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
| 734 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
| 735 | 735 | $data = []; |
| 736 | 736 | $now = new \DateTime(); |
| 737 | 737 | $end = $now->format('Y-m-d'); |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | $recommendations = ''; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - return (string)$recommendations; |
|
| 752 | + return (string) $recommendations; |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | /** |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | { |
| 762 | 762 | $cache = Craft::$app->getCache(); |
| 763 | 763 | // See if there are any recommendations to add as a badge |
| 764 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
| 764 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
| 765 | 765 | $now = new \DateTime(); |
| 766 | 766 | $end = $now->format('Y-m-d'); |
| 767 | 767 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -775,6 +775,6 @@ discard block |
||
| 775 | 775 | $errors = '⚠'; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - return (string)$errors; |
|
| 778 | + return (string) $errors; |
|
| 779 | 779 | } |
| 780 | 780 | } |