@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public function getRecentStatistics($days = 1, $handled = false): array |
| 78 | 78 | { |
| 79 | 79 | // Ensure is an int |
| 80 | - $handledInt = (int)$handled; |
|
| 80 | + $handledInt = (int) $handled; |
|
| 81 | 81 | $stats = []; |
| 82 | 82 | $db = Craft::$app->getDb(); |
| 83 | 83 | if ($db->getIsMysql()) { |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | $stats->userAgent = $userAgent; |
| 213 | 213 | $stats->exceptionMessage = $exceptionMessage; |
| 214 | 214 | $stats->exceptionFilePath = $exceptionFilePath; |
| 215 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
| 215 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
| 216 | 216 | $stats->hitLastTime = Db::prepareDateForDb(new DateTime()); |
| 217 | - $stats->handledByRetour = (int)$handled; |
|
| 217 | + $stats->handledByRetour = (int) $handled; |
|
| 218 | 218 | $stats->hitCount++; |
| 219 | 219 | $statsConfig = $stats->getAttributes(); |
| 220 | 220 | // Record the updated statistics |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $now = round(microtime(true) * 1000); |
| 359 | 359 | $cache = Craft::$app->getCache(); |
| 360 | 360 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
| 361 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
| 361 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
| 362 | 362 | $limited = true; |
| 363 | 363 | } |
| 364 | 364 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | try { |
| 283 | 283 | $siteId = $redirect['siteId'] ?? null; |
| 284 | 284 | if ($siteId !== null) { |
| 285 | - $siteId = (int)$siteId; |
|
| 285 | + $siteId = (int) $siteId; |
|
| 286 | 286 | } |
| 287 | 287 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
| 288 | 288 | } catch (\yii\base\Exception $e) { |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | // That's ok |
| 298 | 298 | } |
| 299 | 299 | if (!empty($queryString)) { |
| 300 | - $dest = strtok($dest, '?') . '?' . $queryString; |
|
| 300 | + $dest = strtok($dest, '?').'?'.$queryString; |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | public function getRedirectFromCache($url, ?int $siteId = 0) |
| 413 | 413 | { |
| 414 | 414 | $cache = Craft::$app->getCache(); |
| 415 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 415 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 416 | 416 | $redirect = $cache->get($cacheKey); |
| 417 | 417 | Craft::info( |
| 418 | 418 | Craft::t( |
@@ -440,12 +440,12 @@ discard block |
||
| 440 | 440 | } catch (SiteNotFoundException $e) { |
| 441 | 441 | $siteId = 1; |
| 442 | 442 | } |
| 443 | - $cacheKey = $this::CACHE_KEY . md5($url) . $siteId; |
|
| 443 | + $cacheKey = $this::CACHE_KEY.md5($url).$siteId; |
|
| 444 | 444 | // Create the dependency tags |
| 445 | 445 | $dependency = new TagDependency([ |
| 446 | 446 | 'tags' => [ |
| 447 | 447 | $this::GLOBAL_REDIRECTS_CACHE_TAG, |
| 448 | - $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId, |
|
| 448 | + $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId, |
|
| 449 | 449 | ], |
| 450 | 450 | ]); |
| 451 | 451 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | foreach ($redirects as $redirect) { |
| 486 | 486 | // Figure out what type of source matching to do |
| 487 | 487 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
| 488 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
| 488 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
| 489 | 489 | if ($redirectEnabled === true) { |
| 490 | 490 | switch ($redirectSrcMatch) { |
| 491 | 491 | case 'pathonly': |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | // Do a regex match |
| 528 | 528 | case 'regexmatch': |
| 529 | - $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i'; |
|
| 529 | + $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i'; |
|
| 530 | 530 | try { |
| 531 | 531 | if (preg_match($matchRegEx, $url) === 1) { |
| 532 | 532 | $this->incrementRedirectHitCount($redirect); |
| 533 | 533 | // If we're not associated with an EntryID, handle capture group replacement |
| 534 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
| 534 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
| 535 | 535 | $redirect['redirectDestUrl'] = preg_replace( |
| 536 | 536 | $matchRegEx, |
| 537 | 537 | $redirect['redirectDestUrl'], |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | } |
| 560 | 560 | } catch (\Exception $e) { |
| 561 | 561 | // That's fine |
| 562 | - Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); |
|
| 562 | + Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | break; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { |
| 668 | 668 | /** @var Plugin $plugin */ |
| 669 | 669 | if (method_exists($plugin, 'retourMatch')) { |
| 670 | - $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match'); |
|
| 670 | + $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); |
|
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | $db = Craft::$app->getDb(); |
| 909 | 909 | // Trigger a 'beforeDeleteRedirect' event |
| 910 | 910 | $redirectConfig = $this->getRedirectById($id); |
| 911 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 911 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 912 | 912 | $event = new RedirectEvent([ |
| 913 | 913 | 'isNew' => $isNew, |
| 914 | 914 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | 'id' => $redirectConfig['id'], |
| 970 | 970 | ] |
| 971 | 971 | )->execute(); |
| 972 | - Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); |
|
| 972 | + Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); |
|
| 973 | 973 | } catch (\Exception $e) { |
| 974 | 974 | Craft::error($e->getMessage(), __METHOD__); |
| 975 | 975 | } |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | // Get the validated model attributes and save them to the db |
| 1082 | 1082 | $redirectConfig = $redirect->getAttributes(); |
| 1083 | 1083 | // 0 for a siteId needs to be converted to null |
| 1084 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
| 1084 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
| 1085 | 1085 | $redirectConfig['siteId'] = null; |
| 1086 | 1086 | } |
| 1087 | 1087 | // Throw an event to before saving the redirect |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | // See if a redirect exists with this source URL already |
| 1094 | - if ((int)$redirectConfig['id'] === 0) { |
|
| 1094 | + if ((int) $redirectConfig['id'] === 0) { |
|
| 1095 | 1095 | // Query the db table |
| 1096 | 1096 | $redirect = (new Query()) |
| 1097 | 1097 | ->from(['{{%retour_static_redirects}}']) |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | // Trigger a 'beforeSaveRedirect' event |
| 1107 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
| 1107 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
| 1108 | 1108 | $event = new RedirectEvent([ |
| 1109 | 1109 | 'isNew' => $isNew, |
| 1110 | 1110 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -1207,13 +1207,13 @@ discard block |
||
| 1207 | 1207 | */ |
| 1208 | 1208 | public function excludeUri($uri): bool |
| 1209 | 1209 | { |
| 1210 | - $uri = '/' . ltrim($uri, '/'); |
|
| 1210 | + $uri = '/'.ltrim($uri, '/'); |
|
| 1211 | 1211 | if (!empty(Retour::$settings->excludePatterns)) { |
| 1212 | 1212 | foreach (Retour::$settings->excludePatterns as $excludePattern) { |
| 1213 | 1213 | if (empty($excludePattern['pattern'])) { |
| 1214 | 1214 | continue; |
| 1215 | 1215 | } |
| 1216 | - $pattern = '`' . $excludePattern['pattern'] . '`i'; |
|
| 1216 | + $pattern = '`'.$excludePattern['pattern'].'`i'; |
|
| 1217 | 1217 | try { |
| 1218 | 1218 | if (preg_match($pattern, $uri) === 1) { |
| 1219 | 1219 | Craft::info( |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | } catch (\Exception $e) { |
| 1231 | 1231 | // That's fine |
| 1232 | - Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); |
|
| 1232 | + Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | } |
| 1235 | 1235 | } |