Completed
Pull Request — master (#81)
by Michal
07:21
created
src/Params/JsonInputParam.php 1 patch
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
 use Exception;
8 8
 use Nette\Application\UI\Form;
9 9
 use Nette\Forms\Controls\BaseControl;
10
-use Tomaj\NetteApi\Validation\JsonSchemaValidator;
11 10
 use Tomaj\NetteApi\ValidationResult\ValidationResult;
12 11
 use Tomaj\NetteApi\ValidationResult\ValidationResultInterface;
12
+use Tomaj\NetteApi\Validation\JsonSchemaValidator;
13 13
 
14 14
 class JsonInputParam extends InputParam
15 15
 {
Please login to merge, or discard this patch.
src/Handlers/OpenApiHandler.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -283,6 +283,9 @@  discard block
 block discarded – undo
283 283
         return $list;
284 284
     }
285 285
 
286
+    /**
287
+     * @param string $baseUrl
288
+     */
286 289
     private function getBasePath($handlers, $baseUrl)
287 290
     {
288 291
         $basePath = null;
@@ -292,6 +295,9 @@  discard block
 block discarded – undo
292 295
         return rtrim(str_replace($baseUrl, '', $basePath), '/');
293 296
     }
294 297
 
298
+    /**
299
+     * @param string $path2
300
+     */
295 301
     private function getLongestCommonSubstring($path1, $path2)
296 302
     {
297 303
         if ($path1 === null) {
@@ -421,6 +427,9 @@  discard block
 block discarded – undo
421 427
         return null;
422 428
     }
423 429
 
430
+    /**
431
+     * @param string $type
432
+     */
424 433
     private function createIn($type)
425 434
     {
426 435
         if ($type == InputParam::TYPE_GET) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             'paths' => $this->getPaths($apis, $baseUrl, $basePath),
157 157
         ];
158 158
 
159
-        if (!empty($this->definitions)) {
159
+        if ( ! empty($this->definitions)) {
160 160
             $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']);
161 161
         }
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
     private function getApis(int $version): array
172 172
     {
173
-        return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) {
173
+        return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) {
174 174
             return $version === $api->getEndpoint()->getVersion();
175 175
         });
176 176
     }
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
             }
262 262
 
263 263
             $parameters = $this->createParamsList($handler);
264
-            if (!empty($parameters)) {
264
+            if ( ! empty($parameters)) {
265 265
                 $settings['parameters'] = $parameters;
266 266
             }
267 267
 
268 268
             $requestBody = $this->createRequestBody($handler);
269
-            if (!empty($requestBody)) {
269
+            if ( ! empty($requestBody)) {
270 270
                 $settings['requestBody'] = $requestBody;
271 271
             }
272 272
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             }
398 398
         }
399 399
 
400
-        if (!empty($postParams['properties'])) {
400
+        if ( ! empty($postParams['properties'])) {
401 401
             $postParamsSchema = [
402 402
                 'type' => 'object',
403 403
                 'properties' => $postParams['properties'],
Please login to merge, or discard this patch.
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.