Passed
Push — v3 ( 9905e0...d51017 )
by Andrew
16:03 queued 16s
created
src/services/Redirects.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                     try {
282 282
                         $siteId = $redirect['siteId'] ?? null;
283 283
                         if ($siteId !== null) {
284
-                            $siteId = (int)$siteId;
284
+                            $siteId = (int) $siteId;
285 285
                         }
286 286
                         if (!UrlHelper::isAbsoluteUrl($dest) && !UrlHelper::pathHasSitePrefix($path) && Retour::$settings->resolveCraftSites) {
287 287
                             $dest = UrlHelper::siteUrl('/', null, null, $siteId);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                 try {
304 304
                     $siteId = $redirect['siteId'] ?? null;
305 305
                     if ($siteId !== null) {
306
-                        $siteId = (int)$siteId;
306
+                        $siteId = (int) $siteId;
307 307
                     }
308 308
                     $dest = UrlHelper::siteUrl($dest, null, null, $siteId);
309 309
                 } catch (\yii\base\Exception $e) {
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
                     // That's ok
319 319
                 }
320 320
                 if (!empty($queryString)) {
321
-                    $dest = strtok($dest, '?') . '?' . $queryString;
321
+                    $dest = strtok($dest, '?').'?'.$queryString;
322 322
                 }
323 323
             }
324 324
             $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     public function getRedirectFromCache($url, ?int $siteId = 0)
440 440
     {
441 441
         $cache = Craft::$app->getCache();
442
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
442
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
443 443
         $redirect = $cache->get($cacheKey);
444 444
         Craft::info(
445 445
             Craft::t(
@@ -467,12 +467,12 @@  discard block
 block discarded – undo
467 467
         } catch (SiteNotFoundException $e) {
468 468
             $siteId = 1;
469 469
         }
470
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
470
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
471 471
         // Create the dependency tags
472 472
         $dependency = new TagDependency([
473 473
             'tags' => [
474 474
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
475
-                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
475
+                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
476 476
             ],
477 477
         ]);
478 478
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         foreach ($redirects as $redirect) {
513 513
             // Figure out what type of source matching to do
514 514
             $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
515
-            $redirectEnabled = (bool)$redirect['enabled'];
515
+            $redirectEnabled = (bool) $redirect['enabled'];
516 516
             if ($redirectEnabled === true) {
517 517
                 switch ($redirectSrcMatch) {
518 518
                     case 'pathonly':
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 
554 554
                     // Do a regex match
555 555
                     case 'regexmatch':
556
-                        $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i';
556
+                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
557 557
                         try {
558 558
                             if (preg_match($matchRegEx, $url) === 1) {
559 559
                                 $this->incrementRedirectHitCount($redirect);
560 560
                                 // If we're not associated with an EntryID, handle capture group replacement
561
-                                if ((int)$redirect['associatedElementId'] === 0) {
561
+                                if ((int) $redirect['associatedElementId'] === 0) {
562 562
                                     $redirect['redirectDestUrl'] = preg_replace(
563 563
                                         $matchRegEx,
564 564
                                         $redirect['redirectDestUrl'],
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                             }
587 587
                         } catch (\Exception $e) {
588 588
                             // That's fine
589
-                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
589
+                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
590 590
                         }
591 591
 
592 592
                         break;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
695 695
             /** @var Plugin $plugin */
696 696
             if (method_exists($plugin, 'retourMatch')) {
697
-                $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match');
697
+                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
698 698
             }
699 699
         }
700 700
 
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
         $db = Craft::$app->getDb();
936 936
         // Trigger a 'beforeDeleteRedirect' event
937 937
         $redirectConfig = $this->getRedirectById($id);
938
-        $isNew = (int)$redirectConfig['id'] === 0;
938
+        $isNew = (int) $redirectConfig['id'] === 0;
939 939
         $event = new RedirectEvent([
940 940
             'isNew' => $isNew,
941 941
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                         'id' => $redirectConfig['id'],
997 997
                     ]
998 998
                 )->execute();
999
-                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
999
+                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
1000 1000
             } catch (\Exception $e) {
1001 1001
                 Craft::error($e->getMessage(), __METHOD__);
1002 1002
             }
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
         // Get the validated model attributes and save them to the db
1113 1113
         $redirectConfig = $redirect->getAttributes();
1114 1114
         // 0 for a siteId needs to be converted to null
1115
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
1115
+        if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) {
1116 1116
             $redirectConfig['siteId'] = null;
1117 1117
         }
1118 1118
         // Throw an event to before saving the redirect
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
         }
1123 1123
 
1124 1124
         // See if a redirect exists with this source URL already
1125
-        if ((int)$redirectConfig['id'] === 0) {
1125
+        if ((int) $redirectConfig['id'] === 0) {
1126 1126
             // Query the db table
1127 1127
             $redirect = (new Query())
1128 1128
                 ->from(['{{%retour_static_redirects}}'])
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
             }
1136 1136
         }
1137 1137
         // Trigger a 'beforeSaveRedirect' event
1138
-        $isNew = (int)$redirectConfig['id'] === 0;
1138
+        $isNew = (int) $redirectConfig['id'] === 0;
1139 1139
         $event = new RedirectEvent([
1140 1140
             'isNew' => $isNew,
1141 1141
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -1214,13 +1214,13 @@  discard block
 block discarded – undo
1214 1214
      */
1215 1215
     public function excludeUri($uri): bool
1216 1216
     {
1217
-        $uri = '/' . ltrim($uri, '/');
1217
+        $uri = '/'.ltrim($uri, '/');
1218 1218
         if (!empty(Retour::$settings->excludePatterns)) {
1219 1219
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
1220 1220
                 if (empty($excludePattern['pattern'])) {
1221 1221
                     continue;
1222 1222
                 }
1223
-                $pattern = '`' . $excludePattern['pattern'] . '`i';
1223
+                $pattern = '`'.$excludePattern['pattern'].'`i';
1224 1224
                 try {
1225 1225
                     if (preg_match($pattern, $uri) === 1) {
1226 1226
                         Craft::info(
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
                     }
1237 1237
                 } catch (\Exception $e) {
1238 1238
                     // That's fine
1239
-                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
1239
+                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
1240 1240
                 }
1241 1241
             }
1242 1242
         }
Please login to merge, or discard this patch.