@@ -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 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function onKernelController(FilterControllerEvent $event): void |
| 60 | 60 | { |
| 61 | - $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count'); |
|
| 62 | - $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time'); |
|
| 61 | + $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count'); |
|
| 62 | + $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time'); |
|
| 63 | 63 | $request = $event->getRequest(); |
| 64 | 64 | |
| 65 | 65 | $this->temporaryBlacklisting($request); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $controller = $event->getController(); |
| 73 | - $loggedIn = (bool) $this->container->get('session')->get('logged_in_user'); |
|
| 73 | + $loggedIn = (bool)$this->container->get('session')->get('logged_in_user'); |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Rate limiting will not apply to these actions |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $cacheItem = $cache->getItem($cacheKey); |
| 95 | 95 | |
| 96 | 96 | // If increment value already in cache, or start with 1. |
| 97 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
| 97 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
| 98 | 98 | |
| 99 | 99 | // Check if limit has been exceeded, and if so, throw an error. |
| 100 | 100 | if ($count > $this->rateLimit) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 154 | 154 | $logger->info( |
| 155 | 155 | "<URI>: ".$request->getRequestUri().' TEMPORARY BLACKLISTING'. |
| 156 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 156 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | 159 | throw new HttpException( |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | // Log the denied request |
| 175 | 175 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 176 | 176 | $logger->info( |
| 177 | - "<URI>: " . $request->getRequestUri() . |
|
| 178 | - ('' != $logComment ? "\t<Reason>: $logComment" : '') . |
|
| 179 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 177 | + "<URI>: ".$request->getRequestUri(). |
|
| 178 | + ('' != $logComment ? "\t<Reason>: $logComment" : ''). |
|
| 179 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 180 | 180 | ); |
| 181 | 181 | |
| 182 | 182 | throw new TooManyRequestsHttpException(600, 'error-rate-limit', null, $this->rateDuration); |