@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $outputValid = count($outputs) === 0; // back compatibility for handlers with no outputs defined |
| 104 | 104 | $outputValidatorErrors = []; |
| 105 | 105 | foreach ($outputs as $output) { |
| 106 | - if (!$output instanceof OutputInterface) { |
|
| 106 | + if ( ! $output instanceof OutputInterface) { |
|
| 107 | 107 | $outputValidatorErrors[] = ["Output does not implement OutputInterface"]; |
| 108 | 108 | continue; |
| 109 | 109 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $outputValidatorErrors[] = $validationResult->getErrors(); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if (!$outputValid) { |
|
| 120 | + if ( ! $outputValid) { |
|
| 121 | 121 | $response = $this->errorHandler->handleSchema($outputValidatorErrors, $params); |
| 122 | 122 | $code = $response->getCode(); |
| 123 | 123 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | private function checkAuth(ApiAuthorizationInterface $authorization, array $params): ?IResponse |
| 154 | 154 | { |
| 155 | 155 | try { |
| 156 | - if (!$authorization->authorized()) { |
|
| 156 | + if ( ! $authorization->authorized()) { |
|
| 157 | 157 | $response = $this->errorHandler->handleAuthorization($authorization, $params); |
| 158 | 158 | $this->response->setCode($response->getCode()); |
| 159 | 159 | return $response; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse |
| 171 | 171 | { |
| 172 | 172 | $rateLimitResponse = $rateLimit->check(); |
| 173 | - if (!$rateLimitResponse) { |
|
| 173 | + if ( ! $rateLimitResponse) { |
|
| 174 | 174 | return null; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | $remaining = $rateLimitResponse->getRemaining(); |
| 179 | 179 | $retryAfter = $rateLimitResponse->getRetryAfter(); |
| 180 | 180 | |
| 181 | - $this->response->addHeader('X-RateLimit-Limit', (string)$limit); |
|
| 182 | - $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining); |
|
| 181 | + $this->response->addHeader('X-RateLimit-Limit', (string) $limit); |
|
| 182 | + $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining); |
|
| 183 | 183 | |
| 184 | 184 | if ($remaining === 0) { |
| 185 | 185 | $this->response->setCode(Response::S429_TOO_MANY_REQUESTS); |
| 186 | - $this->response->addHeader('Retry-After', (string)$retryAfter); |
|
| 186 | + $this->response->addHeader('Retry-After', (string) $retryAfter); |
|
| 187 | 187 | return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -247,12 +247,12 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | private function getRequestDomain(): ?string |
| 249 | 249 | { |
| 250 | - if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 250 | + if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) { |
|
| 251 | 251 | return null; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER')); |
| 255 | - if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 255 | + if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) { |
|
| 256 | 256 | return null; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function validate(ResponseInterface $response): ValidationResultInterface |
| 24 | 24 | { |
| 25 | - if (!$response instanceof JsonApiResponse) { |
|
| 25 | + if ( ! $response instanceof JsonApiResponse) { |
|
| 26 | 26 | return new ValidationResult(ValidationResult::STATUS_ERROR); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function validate(ResponseInterface $response): ValidationResultInterface |
| 15 | 15 | { |
| 16 | - if (!$response instanceof RedirectResponse) { |
|
| 16 | + if ( ! $response instanceof RedirectResponse) { |
|
| 17 | 17 | return new ValidationResult(ValidationResult::STATUS_ERROR); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $urlScript = $this->httpRequest->getUrl(); |
| 32 | 32 | $authentication = $this->authentications[$urlScript->getUser()] ?? null; |
| 33 | - if (!$authentication) { |
|
| 33 | + if ( ! $authentication) { |
|
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $result = $this->tokenRepository->validToken($token); |
| 44 | - if (!$result) { |
|
| 44 | + if ( ! $result) { |
|
| 45 | 45 | $this->errorMessage = 'Token doesn\'t exists or isn\'t active'; |
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (!$this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
| 49 | + if ( ! $this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
| 50 | 50 | $this->errorMessage = 'Invalid IP'; |
| 51 | 51 | return false; |
| 52 | 52 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | [$range, $netmask] = explode('/', $range, 2); |
| 110 | 110 | $range_decimal = ip2long($range); |
| 111 | 111 | $ipDecimal = ip2long($ip); |
| 112 | - $wildcard_decimal = 2 ** (32 - (int)$netmask) - 1; |
|
| 112 | + $wildcard_decimal = 2 ** (32 - (int) $netmask) - 1; |
|
| 113 | 113 | $netmask_decimal = ~ $wildcard_decimal; |
| 114 | 114 | return (($ipDecimal & $netmask_decimal) === ($range_decimal & $netmask_decimal)); |
| 115 | 115 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | protected function getFractal(): Manager |
| 86 | 86 | { |
| 87 | - if (!$this->fractal) { |
|
| 87 | + if ( ! $this->fractal) { |
|
| 88 | 88 | throw new InvalidStateException("Fractal manager isn't initialized. Did you call parent::__construct() in your handler constructor?"); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | final public function createLink(array $params = []): string |
| 125 | 125 | { |
| 126 | - if (!$this->linkGenerator) { |
|
| 126 | + if ( ! $this->linkGenerator) { |
|
| 127 | 127 | throw new InvalidStateException("You have setupLinkGenerator for this handler if you want to generate link in this handler"); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if (!$this->endpoint) { |
|
| 130 | + if ( ! $this->endpoint) { |
|
| 131 | 131 | throw new InvalidStateException("You have setEndpoint() for this handler if you want to generate link in this handler"); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue() |
| 12 | 12 | { |
| 13 | - if (!filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) { |
|
| 13 | + if ( ! filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) { |
|
| 14 | 14 | return $_COOKIE[$this->key]; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue() |
| 12 | 12 | { |
| 13 | - if (!filter_has_var(INPUT_POST, $this->key) && isset($_POST[$this->key])) { |
|
| 13 | + if ( ! filter_has_var(INPUT_POST, $this->key) && isset($_POST[$this->key])) { |
|
| 14 | 14 | return $_POST[$this->key]; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue() |
| 12 | 12 | { |
| 13 | - if (!filter_has_var(INPUT_GET, $this->key) && isset($_GET[$this->key])) { |
|
| 13 | + if ( ! filter_has_var(INPUT_GET, $this->key) && isset($_GET[$this->key])) { |
|
| 14 | 14 | return $_GET[$this->key]; |
| 15 | 15 | } |
| 16 | 16 | |