Passed
Push — master ( 91e81d...94d9d8 )
by MusikAnimal
07:34
created
src/AppBundle/EventSubscriber/RateLimitSubscriber.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
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
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function onKernelController(FilterControllerEvent $event): void
65 65
     {
66
-        $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count');
67
-        $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time');
66
+        $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count');
67
+        $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time');
68 68
         $request = $event->getRequest();
69 69
 
70 70
         // Zero values indicate the rate limiting feature should be disabled.
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
 
75 75
         $controller = $event->getController();
76
-        $loggedIn = (bool) $this->container->get('session')->get('logged_in_user');
76
+        $loggedIn = (bool)$this->container->get('session')->get('logged_in_user');
77 77
 
78 78
         /**
79 79
          * Rate limiting will not apply to these actions
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $cacheItem = $cache->getItem($cacheKey);
100 100
 
101 101
         // If increment value already in cache, or start with 1.
102
-        $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1;
102
+        $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1;
103 103
 
104 104
         // Check if limit has been exceeded, and if so, throw an error.
105 105
         if ($count > $this->rateLimit) {
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                         // Log the denied request
131 131
                         $logger = $this->container->get('monolog.logger.rate_limit');
132 132
                         $logger->info(
133
-                            "<URI>: " . $request->getRequestUri() .
134
-                            ('' != $logComment ? "\t<Reason>: $logComment" : '') .
135
-                            "\t<User agent>: " . $request->headers->get('User-Agent')
133
+                            "<URI>: ".$request->getRequestUri().
134
+                            ('' != $logComment ? "\t<Reason>: $logComment" : '').
135
+                            "\t<User agent>: ".$request->headers->get('User-Agent')
136 136
                         );
137 137
 
138 138
                         throw new HttpException(
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
         // Log the denied request
165 165
         $logger = $this->container->get('monolog.logger.rate_limit');
166 166
         $logger->info(
167
-            "<URI>: " . $request->getRequestUri() .
168
-            ('' != $logComment ? "\t<Reason>: $logComment" : '') .
169
-            "\t<User agent>: " . $request->headers->get('User-Agent')
167
+            "<URI>: ".$request->getRequestUri().
168
+            ('' != $logComment ? "\t<Reason>: $logComment" : '').
169
+            "\t<User agent>: ".$request->headers->get('User-Agent')
170 170
         );
171 171
 
172 172
         $message = $this->i18n->msg('error-rate-limit', [
173 173
             $this->rateDuration,
174 174
             "<a href='/login'>".$this->i18n->msg('error-rate-limit-login')."</a>",
175
-            "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>" .
176
-                $this->i18n->msg('api') .
175
+            "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>".
176
+                $this->i18n->msg('api').
177 177
             "</a>",
178 178
         ]);
179 179
 
Please login to merge, or discard this patch.