| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | |
| 44 | 44 |          if (!empty($string)) { | 
| 45 | 45 | $string = strip_tags($string); | 
| 46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); | |
| 46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | return $result; | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 | |
| 68 | 68 |          if (!empty($string)) { | 
| 69 | 69 | $string = strip_tags($string); | 
| 70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); | |
| 70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); | |
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | 73 | return $result; | 
| @@ -5,12 +5,12 @@ | ||
| 5 | 5 |  ini_set('date.timezone', 'UTC'); | 
| 6 | 6 | |
| 7 | 7 | // Use the current installation of Craft | 
| 8 | -define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage'); | |
| 9 | -define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates'); | |
| 10 | -define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config'); | |
| 11 | -define('CRAFT_MIGRATIONS_PATH', __DIR__ . '/_craft/migrations'); | |
| 12 | -define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); | |
| 13 | -define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor'); | |
| 8 | +define('CRAFT_STORAGE_PATH', __DIR__.'/_craft/storage'); | |
| 9 | +define('CRAFT_TEMPLATES_PATH', __DIR__.'/_craft/templates'); | |
| 10 | +define('CRAFT_CONFIG_PATH', __DIR__.'/_craft/config'); | |
| 11 | +define('CRAFT_MIGRATIONS_PATH', __DIR__.'/_craft/migrations'); | |
| 12 | +define('CRAFT_TRANSLATIONS_PATH', __DIR__.'/_craft/translations'); | |
| 13 | +define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); | |
| 14 | 14 |  define('CRAFT_TESTS_PATH', __DIR__); | 
| 15 | 15 | |
| 16 | 16 | $devMode = true; | 
| @@ -102,14 +102,14 @@ discard block | ||
| 102 | 102 |                      if (strcmp($oldUri, $newUri) !== 0) { | 
| 103 | 103 | // Handle trailing slash config setting | 
| 104 | 104 |                          if (Craft::$app->config->general->addTrailingSlashesToUrls) { | 
| 105 | - $oldUri = rtrim($oldUri, '/') . '/'; | |
| 106 | - $newUri = rtrim($newUri, '/') . '/'; | |
| 105 | + $oldUri = rtrim($oldUri, '/').'/'; | |
| 106 | + $newUri = rtrim($newUri, '/').'/'; | |
| 107 | 107 | } | 
| 108 | 108 | // Handle the URL match type | 
| 109 | 109 |                          if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { | 
| 110 | 110 |                              try { | 
| 111 | 111 |                                  if ($redirectSiteId !== null) { | 
| 112 | - $redirectSiteId = (int)$redirectSiteId; | |
| 112 | + $redirectSiteId = (int) $redirectSiteId; | |
| 113 | 113 | } | 
| 114 | 114 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); | 
| 115 | 115 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); | 
| @@ -127,7 +127,7 @@ discard block | ||
| 127 | 127 | 'siteId' => $redirectSiteId, | 
| 128 | 128 | ]; | 
| 129 | 129 | // Trigger a 'beforeSaveEntryRedirect' event | 
| 130 | - $isNew = (int)$redirectConfig['id'] === 0; | |
| 130 | + $isNew = (int) $redirectConfig['id'] === 0; | |
| 131 | 131 | $event = new RedirectEvent([ | 
| 132 | 132 | 'isNew' => $isNew, | 
| 133 | 133 | 'legacyUrl' => $redirectConfig['redirectSrcUrl'], | 
| @@ -79,7 +79,7 @@ discard block | ||
| 79 | 79 | public function getRecentStatistics($days = 1, $handled = false): array | 
| 80 | 80 |      { | 
| 81 | 81 | // Ensure is an int | 
| 82 | - $handledInt = (int)$handled; | |
| 82 | + $handledInt = (int) $handled; | |
| 83 | 83 | $stats = []; | 
| 84 | 84 | $db = Craft::$app->getDb(); | 
| 85 | 85 |          if ($db->getIsMysql()) { | 
| @@ -210,9 +210,9 @@ discard block | ||
| 210 | 210 | $stats->userAgent = $userAgent; | 
| 211 | 211 | $stats->exceptionMessage = $exceptionMessage; | 
| 212 | 212 | $stats->exceptionFilePath = $exceptionFilePath; | 
| 213 | - $stats->exceptionFileLine = (int)$exceptionFileLine; | |
| 213 | + $stats->exceptionFileLine = (int) $exceptionFileLine; | |
| 214 | 214 | $stats->hitLastTime = Db::prepareDateForDb(new \DateTime()); | 
| 215 | - $stats->handledByRetour = (int)$handled; | |
| 215 | + $stats->handledByRetour = (int) $handled; | |
| 216 | 216 | $stats->hitCount++; | 
| 217 | 217 | $statsConfig = $stats->getAttributes(); | 
| 218 | 218 | // Record the updated statistics | 
| @@ -356,7 +356,7 @@ discard block | ||
| 356 | 356 | $now = round(microtime(true) * 1000); | 
| 357 | 357 | $cache = Craft::$app->getCache(); | 
| 358 | 358 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); | 
| 359 | -        if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { | |
| 359 | +        if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { | |
| 360 | 360 | $limited = true; | 
| 361 | 361 | } | 
| 362 | 362 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); | 
| @@ -114,7 +114,7 @@ | ||
| 114 | 114 |              } else { | 
| 115 | 115 | $variables['sitesMenuLabel'] = Craft::t( | 
| 116 | 116 | 'site', | 
| 117 | - $sites->getSiteById((int)$variables['currentSiteId'])->name | |
| 117 | + $sites->getSiteById((int) $variables['currentSiteId'])->name | |
| 118 | 118 | ); | 
| 119 | 119 | } | 
| 120 | 120 |          } else { | 
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | 'COUNT(handledByRetour = 1 or null) as handled_cnt', | 
| 82 | 82 | ]) | 
| 83 | 83 |                  ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )"); | 
| 84 | -            if ((int)$siteId !== 0) { | |
| 84 | +            if ((int) $siteId !== 0) { | |
| 85 | 85 | $query->andWhere(['siteId' => $siteId]); | 
| 86 | 86 | } | 
| 87 | 87 | $query | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt", | 
| 100 | 100 | ]) | 
| 101 | 101 |                  ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )"); | 
| 102 | -            if ((int)$siteId !== 0) { | |
| 102 | +            if ((int) $siteId !== 0) { | |
| 103 | 103 | $query->andWhere(['siteId' => $siteId]); | 
| 104 | 104 | } | 
| 105 | 105 | $query | 
| @@ -163,8 +163,8 @@ discard block | ||
| 163 | 163 | } | 
| 164 | 164 |          if ($stats) { | 
| 165 | 165 | $data = [ | 
| 166 | - (int)$stats, | |
| 167 | - (int)$handledStats, | |
| 166 | + (int) $stats, | |
| 167 | + (int) $handledStats, | |
| 168 | 168 | ]; | 
| 169 | 169 | } | 
| 170 | 170 | |
| @@ -251,7 +251,7 @@ discard block | ||
| 251 | 251 |          if ($redirectConfig === null) { | 
| 252 | 252 |              throw new NotFoundHttpException('Redirect not found'); | 
| 253 | 253 | } | 
| 254 | - $redirectConfig['id'] = (int)$redirectConfig['id']; | |
| 254 | + $redirectConfig['id'] = (int) $redirectConfig['id']; | |
| 255 | 255 | // Handle enforcing trailing slashes | 
| 256 | 256 | $generalConfig = Craft::$app->getConfig()->getGeneral(); | 
| 257 | 257 |          if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') { | 
| @@ -314,13 +314,13 @@ discard block | ||
| 314 | 314 |          if (!preg_match('/\.[^\/]+$/', $url) && strpos($url, '?') === false) { | 
| 315 | 315 | // If it's a root relative URL, assume it's a site URL | 
| 316 | 316 |              if (UrlHelper::isRootRelativeUrl($url)) { | 
| 317 | - return rtrim($url, '/') . '/'; | |
| 317 | + return rtrim($url, '/').'/'; | |
| 318 | 318 | } | 
| 319 | 319 | // If the URL matches any of the site's base URLs, assume it's a site URL | 
| 320 | 320 | $sites = Craft::$app->getSites()->getAllSites(); | 
| 321 | 321 |              foreach ($sites as $site) { | 
| 322 | 322 |                  if (strpos($url, $site->getBaseUrl()) === 0) { | 
| 323 | - return rtrim($url, '/') . '/'; | |
| 323 | + return rtrim($url, '/').'/'; | |
| 324 | 324 | } | 
| 325 | 325 | } | 
| 326 | 326 | } | 
| @@ -299,7 +299,7 @@ discard block | ||
| 299 | 299 |      { | 
| 300 | 300 | $csv->setOffset(1); | 
| 301 | 301 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); | 
| 302 | -        $csv->each(function ($row) use ($headers, $columns) { | |
| 302 | +        $csv->each(function($row) use ($headers, $columns) { | |
| 303 | 303 | $redirectConfig = [ | 
| 304 | 304 | 'id' => 0, | 
| 305 | 305 | ]; | 
| @@ -312,7 +312,7 @@ discard block | ||
| 312 | 312 | } | 
| 313 | 313 | $index++; | 
| 314 | 314 | } | 
| 315 | -            Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); | |
| 315 | +            Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); | |
| 316 | 316 | Retour::$plugin->redirects->saveRedirect($redirectConfig); | 
| 317 | 317 | |
| 318 | 318 | return true; | 
| @@ -345,7 +345,7 @@ discard block | ||
| 345 | 345 | } | 
| 346 | 346 | $index++; | 
| 347 | 347 | } | 
| 348 | -            Craft::debug('Importing row: ' . print_r($redirectConfig, true), __METHOD__); | |
| 348 | +            Craft::debug('Importing row: '.print_r($redirectConfig, true), __METHOD__); | |
| 349 | 349 | Retour::$plugin->redirects->saveRedirect($redirectConfig); | 
| 350 | 350 | } | 
| 351 | 351 | } | 
| @@ -41,17 +41,17 @@ | ||
| 41 | 41 | $retourType = GqlEntityRegistry::getEntity($typeName) | 
| 42 | 42 | ?: GqlEntityRegistry::createEntity($typeName, new RetourType([ | 
| 43 | 43 | 'name' => $typeName, | 
| 44 | -                'args' => function () use ($retourArgs) { | |
| 44 | +                'args' => function() use ($retourArgs) { | |
| 45 | 45 | return $retourArgs; | 
| 46 | 46 | }, | 
| 47 | -                'fields' => function () use ($retourFields) { | |
| 47 | +                'fields' => function() use ($retourFields) { | |
| 48 | 48 | return $retourFields; | 
| 49 | 49 | }, | 
| 50 | 50 | 'description' => 'This entity has all the Retour fields', | 
| 51 | 51 | ])); | 
| 52 | 52 | |
| 53 | 53 | $gqlTypes[$typeName] = $retourType; | 
| 54 | -        TypeLoader::registerType($typeName, function () use ($retourType) { | |
| 54 | +        TypeLoader::registerType($typeName, function() use ($retourType) { | |
| 55 | 55 | return $retourType; | 
| 56 | 56 | }); | 
| 57 | 57 | |