@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $paramsProcessor = new ParamsProcessor($handler->params()); |
| 84 | 84 | if ($paramsProcessor->isError()) { |
| 85 | 85 | $this->response->setCode(Response::S400_BAD_REQUEST); |
| 86 | - if (!Debugger::$productionMode) { |
|
| 86 | + if ( ! Debugger::$productionMode) { |
|
| 87 | 87 | $response = new JsonResponse(['status' => 'error', 'message' => 'wrong input', 'detail' => $paramsProcessor->getErrors()]); |
| 88 | 88 | } else { |
| 89 | 89 | $response = new JsonResponse(['status' => 'error', 'message' => 'wrong input']); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $outputValid = count($handler->outputs()) === 0; // back compatibility for handlers with no outputs defined |
| 98 | 98 | $outputValidatorErrors = []; |
| 99 | 99 | foreach ($handler->outputs() as $output) { |
| 100 | - if (!$output instanceof OutputInterface) { |
|
| 100 | + if ( ! $output instanceof OutputInterface) { |
|
| 101 | 101 | $outputValidatorErrors[] = ["Output does not implement OutputInterface"]; |
| 102 | 102 | continue; |
| 103 | 103 | } |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | $outputValidatorErrors[] = $validationResult->getErrors(); |
| 110 | 110 | } |
| 111 | - if (!$outputValid) { |
|
| 111 | + if ( ! $outputValid) { |
|
| 112 | 112 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'details' => $outputValidatorErrors]); |
| 113 | 113 | } |
| 114 | 114 | $code = $response->getCode(); |
| 115 | 115 | } catch (Throwable $exception) { |
| 116 | - if (!Debugger::$productionMode) { |
|
| 116 | + if ( ! Debugger::$productionMode) { |
|
| 117 | 117 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'detail' => $exception->getMessage()]); |
| 118 | 118 | } else { |
| 119 | 119 | $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error']); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | private function checkAuth(ApiAuthorizationInterface $authorization): ?IResponse |
| 149 | 149 | { |
| 150 | - if (!$authorization->authorized()) { |
|
| 150 | + if ( ! $authorization->authorized()) { |
|
| 151 | 151 | $this->response->setCode(Response::S403_FORBIDDEN); |
| 152 | 152 | return new JsonResponse(['status' => 'error', 'message' => $authorization->getErrorMessage()]); |
| 153 | 153 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse |
| 158 | 158 | { |
| 159 | 159 | $rateLimitResponse = $rateLimit->check(); |
| 160 | - if (!$rateLimitResponse) { |
|
| 160 | + if ( ! $rateLimitResponse) { |
|
| 161 | 161 | return null; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | $remaining = $rateLimitResponse->getRemaining(); |
| 166 | 166 | $retryAfter = $rateLimitResponse->getRetryAfter(); |
| 167 | 167 | |
| 168 | - $this->response->addHeader('X-RateLimit-Limit', (string)$limit); |
|
| 169 | - $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining); |
|
| 168 | + $this->response->addHeader('X-RateLimit-Limit', (string) $limit); |
|
| 169 | + $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining); |
|
| 170 | 170 | |
| 171 | 171 | if ($remaining === 0) { |
| 172 | 172 | $this->response->setCode(Response::S429_TOO_MANY_REQUESTS); |
| 173 | - $this->response->addHeader('Retry-After', (string)$retryAfter); |
|
| 173 | + $this->response->addHeader('Retry-After', (string) $retryAfter); |
|
| 174 | 174 | return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']); |
| 175 | 175 | } |
| 176 | 176 | return null; |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | private function getRequestDomain(): ?string |
| 234 | 234 | { |
| 235 | - if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 235 | + if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 236 | 236 | return null; |
| 237 | 237 | } |
| 238 | 238 | $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER')); |
| 239 | - if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 239 | + if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 240 | 240 | return null; |
| 241 | 241 | } |
| 242 | 242 | $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host']; |