@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the RateLimitSubscriber class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace AppBundle\EventSubscriber; |
| 9 | 9 | |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function onKernelController(FilterControllerEvent $event): void |
| 66 | 66 | { |
| 67 | - $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count'); |
|
| 68 | - $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time'); |
|
| 67 | + $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count'); |
|
| 68 | + $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time'); |
|
| 69 | 69 | $request = $event->getRequest(); |
| 70 | 70 | |
| 71 | 71 | $this->temporaryBlacklisting($request); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $controller = $event->getController(); |
| 79 | - $loggedIn = (bool) $this->container->get('session')->get('logged_in_user'); |
|
| 79 | + $loggedIn = (bool)$this->container->get('session')->get('logged_in_user'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Rate limiting will not apply to these actions |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $cacheItem = $cache->getItem($cacheKey); |
| 103 | 103 | |
| 104 | 104 | // If increment value already in cache, or start with 1. |
| 105 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
| 105 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
| 106 | 106 | |
| 107 | 107 | // Check if limit has been exceeded, and if so, throw an error. |
| 108 | 108 | if ($count > $this->rateLimit) { |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | // Log the denied request |
| 134 | 134 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 135 | 135 | $logger->info( |
| 136 | - "<URI>: " . $request->getRequestUri() . |
|
| 137 | - ('' != $logComment ? "\t<Reason>: $logComment" : '') . |
|
| 138 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 136 | + "<URI>: ".$request->getRequestUri(). |
|
| 137 | + ('' != $logComment ? "\t<Reason>: $logComment" : ''). |
|
| 138 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 139 | 139 | ); |
| 140 | 140 | |
| 141 | 141 | throw new HttpException( |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 201 | 201 | $logger->info( |
| 202 | 202 | "<URI>: ".$request->getRequestUri().' TEMPORARY BLACKLISTING'. |
| 203 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 203 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | throw new HttpException( |
@@ -220,16 +220,16 @@ discard block |
||
| 220 | 220 | // Log the denied request |
| 221 | 221 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 222 | 222 | $logger->info( |
| 223 | - "<URI>: " . $request->getRequestUri() . |
|
| 224 | - ('' != $logComment ? "\t<Reason>: $logComment" : '') . |
|
| 225 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 223 | + "<URI>: ".$request->getRequestUri(). |
|
| 224 | + ('' != $logComment ? "\t<Reason>: $logComment" : ''). |
|
| 225 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 226 | 226 | ); |
| 227 | 227 | |
| 228 | 228 | $message = $this->i18n->msg('error-rate-limit', [ |
| 229 | 229 | $this->rateDuration, |
| 230 | 230 | "<a href='/login'>".$this->i18n->msg('error-rate-limit-login')."</a>", |
| 231 | - "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>" . |
|
| 232 | - $this->i18n->msg('api') . |
|
| 231 | + "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>". |
|
| 232 | + $this->i18n->msg('api'). |
|
| 233 | 233 | "</a>", |
| 234 | 234 | ]); |
| 235 | 235 | |