Passed
Push — v4 ( 538ab1...071aea )
by Andrew
27:15 queued 18:39
created
src/services/ServicesTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
         // so we can't extract it from the passed in $config
40 40
         $majorVersion = '4';
41 41
         // Dev server container name & port are based on the major version of this plugin
42
-        $devPort = 3000 + (int)$majorVersion;
43
-        $versionName = 'v' . $majorVersion;
42
+        $devPort = 3000 + (int) $majorVersion;
43
+        $versionName = 'v'.$majorVersion;
44 44
         return [
45 45
             'components' => [
46 46
                 'events' => Events::class,
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
                     'assetClass' => RetourAsset::class,
52 52
                     'checkDevServer' => true,
53 53
                     'class' => VitePluginService::class,
54
-                    'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort,
55
-                    'devServerPublic' => 'http://localhost:' . $devPort,
54
+                    'devServerInternal' => 'http://craft-retour-'.$versionName.'-buildchain-dev:'.$devPort,
55
+                    'devServerPublic' => 'http://localhost:'.$devPort,
56 56
                     'errorEntry' => 'src/js/Retour.js',
57 57
                     'useDevServer' => true,
58 58
                 ],
Please login to merge, or discard this patch.
src/services/Redirects.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -264,17 +264,17 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function excludeUri($uri): bool
266 266
     {
267
-        $uri = '/' . ltrim($uri, '/');
267
+        $uri = '/'.ltrim($uri, '/');
268 268
         if (!empty(Retour::$settings->excludePatterns)) {
269 269
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
270
-                $pattern = '`' . $excludePattern['pattern'] . '`i';
270
+                $pattern = '`'.$excludePattern['pattern'].'`i';
271 271
                 try {
272 272
                     if (preg_match($pattern, $uri) === 1) {
273 273
                         return true;
274 274
                     }
275 275
                 } catch (\Exception $e) {
276 276
                     // That's fine
277
-                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
277
+                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
278 278
                 }
279 279
             }
280 280
         }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      *
290 290
      * @return bool|array|null
291 291
      */
292
-    public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool|array|null
292
+    public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool | array | null
293 293
     {
294 294
         // Get the current site
295 295
         if ($siteId === null) {
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
      *
345 345
      * @return bool|array
346 346
      */
347
-    public function getRedirectFromCache(string $url, int $siteId = 0): bool|array
347
+    public function getRedirectFromCache(string $url, int $siteId = 0): bool | array
348 348
     {
349 349
         $cache = Craft::$app->getCache();
350
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
350
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
351 351
         $redirect = $cache->get($cacheKey);
352 352
         Craft::info(
353 353
             Craft::t(
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                         'id' => $redirectConfig['id'],
393 393
                     ]
394 394
                 )->execute();
395
-                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
395
+                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
396 396
             } catch (\Exception $e) {
397 397
                 Craft::error($e->getMessage(), __METHOD__);
398 398
             }
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
         } catch (SiteNotFoundException $e) {
414 414
             $siteId = 1;
415 415
         }
416
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
416
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
417 417
         // Create the dependency tags
418 418
         $dependency = new TagDependency([
419 419
             'tags' => [
420 420
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
421
-                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
421
+                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
422 422
             ],
423 423
         ]);
424 424
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
         foreach ($redirects as $redirect) {
645 645
             // Figure out what type of source matching to do
646 646
             $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
647
-            $redirectEnabled = (bool)$redirect['enabled'];
647
+            $redirectEnabled = (bool) $redirect['enabled'];
648 648
             if ($redirectEnabled === true) {
649 649
                 switch ($redirectSrcMatch) {
650 650
                     case 'pathonly':
@@ -685,12 +685,12 @@  discard block
 block discarded – undo
685 685
 
686 686
                     // Do a regex match
687 687
                     case 'regexmatch':
688
-                        $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i';
688
+                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
689 689
                         try {
690 690
                             if (preg_match($matchRegEx, $url) === 1) {
691 691
                                 $this->incrementRedirectHitCount($redirect);
692 692
                                 // If we're not associated with an EntryID, handle capture group replacement
693
-                                if ((int)$redirect['associatedElementId'] === 0) {
693
+                                if ((int) $redirect['associatedElementId'] === 0) {
694 694
                                     $redirect['redirectDestUrl'] = preg_replace(
695 695
                                         $matchRegEx,
696 696
                                         $redirect['redirectDestUrl'],
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
                             }
719 719
                         } catch (\Exception $e) {
720 720
                             // That's fine
721
-                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
721
+                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
722 722
                         }
723 723
 
724 724
                         break;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                 try {
844 844
                     $siteId = $redirect['siteId'] ?? null;
845 845
                     if ($siteId !== null) {
846
-                        $siteId = (int)$siteId;
846
+                        $siteId = (int) $siteId;
847 847
                     }
848 848
                     $dest = UrlHelper::siteUrl($dest, null, null, $siteId);
849 849
                 } catch (\yii\base\Exception $e) {
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
                     // That's ok
859 859
                 }
860 860
                 if (!empty($queryString)) {
861
-                    $dest = strtok($dest, '?') . '?' . $queryString;
861
+                    $dest = strtok($dest, '?').'?'.$queryString;
862 862
                 }
863 863
             }
864 864
             $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
927 927
             /** @var Plugin $plugin */
928 928
             if (method_exists($plugin, 'retourMatch')) {
929
-                $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match');
929
+                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
930 930
             }
931 931
         }
932 932
 
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
         $db = Craft::$app->getDb();
964 964
         // Trigger a 'beforeDeleteRedirect' event
965 965
         $redirectConfig = $this->getRedirectById($id);
966
-        $isNew = (int)$redirectConfig['id'] === 0;
966
+        $isNew = (int) $redirectConfig['id'] === 0;
967 967
         $event = new RedirectEvent([
968 968
             'isNew' => $isNew,
969 969
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
         // Get the validated model attributes and save them to the db
1139 1139
         $redirectConfig = $redirect->getAttributes();
1140 1140
         // 0 for a siteId needs to be converted to null
1141
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
1141
+        if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) {
1142 1142
             $redirectConfig['siteId'] = null;
1143 1143
         }
1144 1144
         // Throw an event to before saving the redirect
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
         }
1149 1149
 
1150 1150
         // See if a redirect exists with this source URL already
1151
-        if ((int)$redirectConfig['id'] === 0) {
1151
+        if ((int) $redirectConfig['id'] === 0) {
1152 1152
             // Query the db table
1153 1153
             $redirect = (new Query())
1154 1154
                 ->from(['{{%retour_static_redirects}}'])
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
             }
1162 1162
         }
1163 1163
         // Trigger a 'beforeSaveRedirect' event
1164
-        $isNew = (int)$redirectConfig['id'] === 0;
1164
+        $isNew = (int) $redirectConfig['id'] === 0;
1165 1165
         $event = new RedirectEvent([
1166 1166
             'isNew' => $isNew,
1167 1167
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
Please login to merge, or discard this patch.
src/services/Statistics.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function getRecentStatistics(int $days = 1, bool $handled = false): array
77 77
     {
78 78
         // Ensure is an int
79
-        $handledInt = (int)$handled;
79
+        $handledInt = (int) $handled;
80 80
         $stats = [];
81 81
         $db = Craft::$app->getDb();
82 82
         if ($db->getIsMysql()) {
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
         $stats->userAgent = $userAgent;
212 212
         $stats->exceptionMessage = $exceptionMessage;
213 213
         $stats->exceptionFilePath = $exceptionFilePath;
214
-        $stats->exceptionFileLine = (int)$exceptionFileLine;
214
+        $stats->exceptionFileLine = (int) $exceptionFileLine;
215 215
         $stats->hitLastTime = Db::prepareDateForDb(new DateTime());
216
-        $stats->handledByRetour = (int)$handled;
216
+        $stats->handledByRetour = (int) $handled;
217 217
         $stats->hitCount++;
218 218
         $statsConfig = $stats->getAttributes();
219 219
         // Record the updated statistics
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         $now = round(microtime(true) * 1000);
287 287
         $cache = Craft::$app->getCache();
288 288
         $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY);
289
-        if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) {
289
+        if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) {
290 290
             $limited = true;
291 291
         }
292 292
         $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0);
Please login to merge, or discard this patch.
src/console/controllers/StatsController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @var    array|bool
40 40
      */
41
-    protected array|bool $allowAnonymous = [
41
+    protected array | bool $allowAnonymous = [
42 42
     ];
43 43
 
44 44
     // Public Methods
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function actionTrim(): int
65 65
     {
66
-        echo Craft::t('retour', 'Trimming statistics') . PHP_EOL;
66
+        echo Craft::t('retour', 'Trimming statistics').PHP_EOL;
67 67
         $affectedRows = Retour::$plugin->statistics->trimStatistics($this->limit);
68 68
         echo Craft::t(
69 69
                 'retour',
70 70
                 'Trimmed {rows} from retour_stats table',
71 71
                 ['rows' => $affectedRows]
72
-            ) . PHP_EOL;
72
+            ).PHP_EOL;
73 73
 
74 74
         return 0;
75 75
     }
Please login to merge, or discard this patch.
src/helpers/FileLog.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
      */
93 93
     public static function getLogFilePath(string $fileName): string
94 94
     {
95
-        $logfile = $fileName . "-" . date(self::FILE_PER_DAY);
95
+        $logfile = $fileName."-".date(self::FILE_PER_DAY);
96 96
 
97 97
         return Craft::getAlias("@storage/logs/$logfile.log");
98 98
     }
Please login to merge, or discard this patch.