Passed
Push — develop ( f2d139...111994 )
by Andrew
03:01
created
src/services/DataSamples.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/base/Recommendation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,6 +45,6 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/controllers/ChartsController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
src/services/ErrorSamples.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
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
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                 ->andWhere(['url' => $pageUrl])
121 121
             ;
122 122
         }
123
-        if ((int)$siteId !== 0) {
123
+        if ((int) $siteId !== 0) {
124 124
             $query->andWhere(['siteId' => $siteId]);
125 125
         }
126 126
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                 ['not', ['title' => '']],
147 147
             ])
148 148
         ;
149
-        if ((int)$siteId !== 0) {
149
+        if ((int) $siteId !== 0) {
150 150
             $query->andWhere(['siteId' => $siteId]);
151 151
         }
152 152
         $result = $query->one();
Please login to merge, or discard this patch.
src/recommendations/MemoryLimit.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function evaluate()
37 37
     {
38
-        $phpMemoryLimit = (int)$this->memoryLimit();
39
-        $this->sample->craftTotalMemory = (int)$this->sample->craftTotalMemory;
38
+        $phpMemoryLimit = (int) $this->memoryLimit();
39
+        $this->sample->craftTotalMemory = (int) $this->sample->craftTotalMemory;
40 40
         if ($phpMemoryLimit && $this->sample->craftTotalMemory) {
41 41
             $ratio = $phpMemoryLimit / $this->sample->craftTotalMemory;
42
-            $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024) . 'M';
43
-            $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024) . 'M';
44
-            $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024) . 'M';
45
-            $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024) . 'M';
42
+            $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024).'M';
43
+            $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024).'M';
44
+            $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024).'M';
45
+            $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024).'M';
46 46
             $this->summary = Craft::t(
47 47
                 'webperf',
48 48
                 'Check the `memory_limit` setting in your `php.ini` file',
@@ -114,6 +114,6 @@  discard block
 block discarded – undo
114 114
             }
115 115
         }
116 116
 
117
-        return (int)$memoryLimit;
117
+        return (int) $memoryLimit;
118 118
     }
119 119
 }
Please login to merge, or discard this patch.
src/controllers/MetricsController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
             if ($userAgent) {
164 164
                 $parser = new Parser($userAgent);
165 165
                 $sample->device = ($parser->device->model ?? '');
166
-                $sample->browser = ($parser->browser->name ?? '') . ' ' . $parser->browser->getVersion();
167
-                $sample->os = ($parser->os->name ?? '') . ' ' . $parser->os->getVersion();
166
+                $sample->browser = ($parser->browser->name ?? '').' '.$parser->browser->getVersion();
167
+                $sample->os = ($parser->os->name ?? '').' '.$parser->os->getVersion();
168 168
                 $sample->mobile = $parser->isMobile();
169 169
             }
170 170
             // Save the data sample
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             $now = round(microtime(true) * 1000);
202 202
             $cache = Craft::$app->getCache();
203 203
             $then = $cache->get(self::LAST_BEACON_CACHE_KEY);
204
-            if (($then !== false) && ($now - (int)$then < Webperf::$settings->rateLimitMs)) {
204
+            if (($then !== false) && ($now - (int) $then < Webperf::$settings->rateLimitMs)) {
205 205
                 $limited = true;
206 206
                 Craft::warning('Beacon ignored due to rate limiting', __METHOD__);
207 207
             }
Please login to merge, or discard this patch.
src/Webperf.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
         Event::on(
324 324
             Plugins::class,
325 325
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
326
-            function (PluginEvent $event) {
326
+            function(PluginEvent $event) {
327 327
                 if ($event->plugin === $this) {
328 328
                     // Invalidate our caches after we've been installed
329 329
                     $this->clearAllCaches();
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         Event::on(
352 352
             CraftVariable::class,
353 353
             CraftVariable::EVENT_INIT,
354
-            function (Event $event) {
354
+            function(Event $event) {
355 355
                 /** @var CraftVariable $variable */
356 356
                 $variable = $event->sender;
357 357
                 $variable->set('webperf', WebperfVariable::class);
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
         Event::on(
362 362
             Plugins::class,
363 363
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
364
-            function () {
364
+            function() {
365 365
                 // Install these only after all other plugins have loaded
366 366
                 $request = Craft::$app->getRequest();
367 367
                 // Only respond to non-console site requests
368
-                if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()  && !$request->getIsLivePreview()) {
368
+                if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest() && !$request->getIsLivePreview()) {
369 369
                     $this->handleSiteRequest();
370 370
                 }
371 371
                 // Respond to Control Panel requests
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
         Event::on(
386 386
             UrlManager::class,
387 387
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
388
-            function (RegisterUrlRulesEvent $event) {
388
+            function(RegisterUrlRulesEvent $event) {
389 389
                 Craft::debug(
390 390
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
391 391
                     __METHOD__
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
         Event::on(
409 409
             UrlManager::class,
410 410
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
411
-            function (RegisterUrlRulesEvent $event) {
411
+            function(RegisterUrlRulesEvent $event) {
412 412
                 Craft::debug(
413 413
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
414 414
                     __METHOD__
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
         Event::on(
425 425
             UserPermissions::class,
426 426
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
427
-            function (RegisterUserPermissionsEvent $event) {
427
+            function(RegisterUserPermissionsEvent $event) {
428 428
                 Craft::debug(
429 429
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
430 430
                     __METHOD__
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             Event::on(
455 455
                 View::class,
456 456
                 View::EVENT_END_PAGE,
457
-                function () {
457
+                function() {
458 458
                     Craft::debug(
459 459
                         'View::EVENT_END_PAGE',
460 460
                         __METHOD__
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
             Event::on(
483 483
                 View::class,
484 484
                 View::EVENT_END_BODY,
485
-                function () {
485
+                function() {
486 486
                     Craft::debug(
487 487
                         'View::EVENT_END_BODY',
488 488
                         __METHOD__
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
             Event::on(
506 506
                 Application::class,
507 507
                 Application::EVENT_AFTER_REQUEST,
508
-                function () {
508
+                function() {
509 509
                     Craft::debug(
510 510
                         'Application::EVENT_AFTER_REQUEST',
511 511
                         __METHOD__
@@ -531,21 +531,21 @@  discard block
 block discarded – undo
531 531
         if (self::$settings->displaySidebar && $currentUser && $currentUser->can('webperf:sidebar')) {
532 532
             $view = Craft::$app->getView();
533 533
             // Entries sidebar
534
-            $view->hook('cp.entries.edit.details', function (&$context) {
534
+            $view->hook('cp.entries.edit.details', function(&$context) {
535 535
                 /** @var  Element $element */
536 536
                 $element = $context['entry'] ?? null;
537 537
 
538 538
                 return $this->renderSidebar($element);
539 539
             });
540 540
             // Category Groups sidebar
541
-            $view->hook('cp.categories.edit.details', function (&$context) {
541
+            $view->hook('cp.categories.edit.details', function(&$context) {
542 542
                 /** @var  Element $element */
543 543
                 $element = $context['category'] ?? null;
544 544
 
545 545
                 return $this->renderSidebar($element);
546 546
             });
547 547
             // Commerce Product Types sidebar
548
-            $view->hook('cp.commerce.product.edit.details', function (&$context) {
548
+            $view->hook('cp.commerce.product.edit.details', function(&$context) {
549 549
                 /** @var  Element $element */
550 550
                 $element = $context['product'] ?? null;
551 551
 
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
     {
766 766
         $cache = Craft::$app->getCache();
767 767
         // See if there are any recommendations to add as a badge
768
-        $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () {
768
+        $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() {
769 769
             $data = [];
770 770
             $now = new \DateTime();
771 771
             $end = $now->format('Y-m-d');
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
             $recommendations = '';
784 784
         }
785 785
 
786
-        return (string)$recommendations;
786
+        return (string) $recommendations;
787 787
     }
788 788
 
789 789
     /**
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
     {
796 796
         $cache = Craft::$app->getCache();
797 797
         // See if there are any recommendations to add as a badge
798
-        $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () {
798
+        $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() {
799 799
             $now = new \DateTime();
800 800
             $end = $now->format('Y-m-d');
801 801
             $start = $now->modify('-30 days')->format('Y-m-d');
@@ -809,6 +809,6 @@  discard block
 block discarded – undo
809 809
             $errors = '⚠';
810 810
         }
811 811
 
812
-        return (string)$errors;
812
+        return (string) $errors;
813 813
     }
814 814
 }
Please login to merge, or discard this patch.