Completed
Push — master ( fbf566...079bfa )
by Michal
03:01 queued 01:16
created
src/Output/RedirectOutput.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 {
12 12
     public function validate(ResponseInterface $response): ValidationResultInterface
13 13
     {
14
-        if (!$response instanceof RedirectResponse) {
14
+        if ( ! $response instanceof RedirectResponse) {
15 15
             return new ValidationResult(ValidationResult::STATUS_ERROR);
16 16
         }
17 17
         if ($this->code !== $response->getCode()) {
Please login to merge, or discard this patch.
src/Presenters/ApiPresenter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                 }
104 104
                 $outputValidatorErrors[] = $validationResult->getErrors();
105 105
             }
106
-            if (!$outputValid) {
106
+            if ( ! $outputValid) {
107 107
                 $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'details' => $outputValidatorErrors]);
108 108
             }
109 109
             $code = $response->getCode();
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
     private function checkAuth(ApiAuthorizationInterface $authorization): ?IResponse
144 144
     {
145
-        if (!$authorization->authorized()) {
145
+        if ( ! $authorization->authorized()) {
146 146
             $this->response->setCode(Response::S403_FORBIDDEN);
147 147
             return new JsonResponse(['status' => 'error', 'message' => $authorization->getErrorMessage()]);
148 148
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse
153 153
     {
154 154
         $rateLimitResponse = $rateLimit->check();
155
-        if (!$rateLimitResponse) {
155
+        if ( ! $rateLimitResponse) {
156 156
             return null;
157 157
         }
158 158
 
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
         $remaining = $rateLimitResponse->getRemaining();
161 161
         $retryAfter = $rateLimitResponse->getRetryAfter();
162 162
 
163
-        $this->response->addHeader('X-RateLimit-Limit', (string)$limit);
164
-        $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining);
163
+        $this->response->addHeader('X-RateLimit-Limit', (string) $limit);
164
+        $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining);
165 165
 
166 166
         if ($remaining === 0) {
167 167
             $this->response->setCode(Response::S429_TOO_MANY_REQUESTS);
168
-            $this->response->addHeader('Retry-After', (string)$retryAfter);
168
+            $this->response->addHeader('Retry-After', (string) $retryAfter);
169 169
             return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']);
170 170
         }
171 171
         return null;
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 
228 228
     private function getRequestDomain(): ?string
229 229
     {
230
-        if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
230
+        if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
231 231
             return null;
232 232
         }
233 233
         $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER'));
234
-        if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
234
+        if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
235 235
             return null;
236 236
         }
237 237
         $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host'];
Please login to merge, or discard this patch.
src/Handlers/OpenApiHandler.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -294,6 +294,9 @@  discard block
 block discarded – undo
294 294
         return rtrim(str_replace($baseUrl, '', $basePath), '/');
295 295
     }
296 296
 
297
+    /**
298
+     * @param string $path2
299
+     */
297 300
     private function getLongestCommonSubstring($path1, $path2)
298 301
     {
299 302
         if ($path1 === null) {
@@ -436,6 +439,9 @@  discard block
 block discarded – undo
436 439
         return null;
437 440
     }
438 441
 
442
+    /**
443
+     * @param string $type
444
+     */
439 445
     private function createIn($type)
440 446
     {
441 447
         if ($type == InputParam::TYPE_GET) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $data = [
95 95
             'openapi' => '3.0.0',
96 96
             'info' => [
97
-                'version' => (string)$version,
97
+                'version' => (string) $version,
98 98
                 'title' => 'Nette API',
99 99
             ],
100 100
             'servers' => [
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             'paths' => $this->getPaths($apis, $baseUrl, $basePath),
159 159
         ];
160 160
 
161
-        if (!empty($this->definitions)) {
161
+        if ( ! empty($this->definitions)) {
162 162
             $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']);
163 163
         }
164 164
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
     private function getApis(int $version): array
174 174
     {
175
-        return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) {
175
+        return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) {
176 176
             return $version === $api->getEndpoint()->getVersion();
177 177
         });
178 178
     }
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
             }
264 264
 
265 265
             $parameters = $this->createParamsList($handler);
266
-            if (!empty($parameters)) {
266
+            if ( ! empty($parameters)) {
267 267
                 $settings['parameters'] = $parameters;
268 268
             }
269 269
 
270 270
             $requestBody = $this->createRequestBody($handler);
271
-            if (!empty($requestBody)) {
271
+            if ( ! empty($requestBody)) {
272 272
                 $settings['requestBody'] = $requestBody;
273 273
             }
274 274
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             }
413 413
         }
414 414
 
415
-        if (!empty($postParams['properties'])) {
415
+        if ( ! empty($postParams['properties'])) {
416 416
             $postParamsSchema = [
417 417
                 'type' => 'object',
418 418
                 'properties' => $postParams['properties'],
Please login to merge, or discard this patch.