@@ -12,11 +12,11 @@ |
||
| 12 | 12 | private const EXPECTED_HTTP_PARTS = 2; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * BearerTokenAuthorization constructor. |
|
| 16 | - * |
|
| 17 | - * @param TokenRepositoryInterface $tokenRepository |
|
| 18 | - * @param IpDetectorInterface $ipDetector |
|
| 19 | - */ |
|
| 15 | + * BearerTokenAuthorization constructor. |
|
| 16 | + * |
|
| 17 | + * @param TokenRepositoryInterface $tokenRepository |
|
| 18 | + * @param IpDetectorInterface $ipDetector |
|
| 19 | + */ |
|
| 20 | 20 | public function __construct(TokenRepositoryInterface $tokenRepository, IpDetectorInterface $ipDetector) |
| 21 | 21 | { |
| 22 | 22 | parent::__construct($tokenRepository, $ipDetector); |
@@ -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 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $range_decimal = ip2long($range); |
| 111 | 111 | $ipDecimal = ip2long($ip); |
| 112 | 112 | /** @phpstan-ignore-next-line */ |
| 113 | - $wildcard_decimal = pow(2, (32 - (int)$netmask)) - 1; |
|
| 113 | + $wildcard_decimal = pow(2, (32 - (int) $netmask)) - 1; |
|
| 114 | 114 | $netmask_decimal = ~ $wildcard_decimal; |
| 115 | 115 | return (($ipDecimal & $netmask_decimal) === ($range_decimal & $netmask_decimal)); |
| 116 | 116 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | public function enableGlobalPreflight(?CorsPreflightHandlerInterface $corsHandler = null): void |
| 59 | 59 | { |
| 60 | - if (!$corsHandler) { |
|
| 60 | + if ( ! $corsHandler) { |
|
| 61 | 61 | $corsHandler = new CorsPreflightHandler(new Response()); |
| 62 | 62 | } |
| 63 | 63 | $this->globalPreflightHandler = $corsHandler; |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | private function getApiList(string $version): array |
| 57 | 57 | { |
| 58 | - $versionApis = array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
| 58 | + $versionApis = array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
| 59 | 59 | return $version === $api->getEndpoint()->getVersion(); |
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | - return array_map(function (Api $api) { |
|
| 62 | + return array_map(function(Api $api) { |
|
| 63 | 63 | return [ |
| 64 | 64 | 'method' => $api->getEndpoint()->getMethod(), |
| 65 | 65 | 'version' => $api->getEndpoint()->getVersion(), |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | private function createParamsList(ApiHandlerInterface $handler): array |
| 83 | 83 | { |
| 84 | 84 | /** @phpstan-ignore-next-line */ |
| 85 | - return array_map(function (InputParam $param): array { |
|
| 85 | + return array_map(function(InputParam $param): array { |
|
| 86 | 86 | $parameter = [ |
| 87 | 87 | 'type' => $param->getType(), |
| 88 | 88 | 'key' => $param->getKey(), |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function getFractal(): Manager |
| 87 | 87 | { |
| 88 | - if (!$this->fractal) { |
|
| 88 | + if ( ! $this->fractal) { |
|
| 89 | 89 | throw new InvalidStateException("Fractal manager isn't initialized. Did you call parent::__construct() in your handler constructor?"); |
| 90 | 90 | } |
| 91 | 91 | return $this->fractal; |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | final public function createLink(array $params = []): string |
| 129 | 129 | { |
| 130 | - if (!$this->linkGenerator) { |
|
| 130 | + if ( ! $this->linkGenerator) { |
|
| 131 | 131 | throw new InvalidStateException('You have setupLinkGenerator for this handler if you want to generate link in this handler'); |
| 132 | 132 | } |
| 133 | - if (!$this->endpoint) { |
|
| 133 | + if ( ! $this->endpoint) { |
|
| 134 | 134 | throw new InvalidStateException('You have setEndpoint() for this handler if you want to generate link in this handler'); |
| 135 | 135 | } |
| 136 | 136 | $params = array_merge([ |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
| 187 | 187 | $cookieFields[$key][] = $valueData; |
| 188 | 188 | } else { |
| 189 | - $getFields[$key][] = urlencode((string)$valueData); |
|
| 189 | + $getFields[$key][] = urlencode((string) $valueData); |
|
| 190 | 190 | } |
| 191 | 191 | } else { |
| 192 | 192 | if (in_array($param->getType(), [InputParam::TYPE_POST, InputParam::TYPE_FILE], true)) { |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | } elseif ($param->getType() === InputParam::TYPE_COOKIE) { |
| 197 | 197 | $cookieFields[$key] = $valueData; |
| 198 | 198 | } else { |
| 199 | - $getFields[$key] = urlencode((string)$valueData); |
|
| 199 | + $getFields[$key] = urlencode((string) $valueData); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | { |
| 245 | 245 | $result = []; |
| 246 | 246 | foreach ($values as $key => $value) { |
| 247 | - if (!is_array($value)) { |
|
| 247 | + if ( ! is_array($value)) { |
|
| 248 | 248 | $result[$key] = $value; |
| 249 | 249 | continue; |
| 250 | 250 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct(string $status, array $errors = []) |
| 23 | 23 | { |
| 24 | - if (!in_array($status, [self::STATUS_OK, self::STATUS_ERROR], true)) { |
|
| 24 | + if ( ! in_array($status, [self::STATUS_OK, self::STATUS_ERROR], true)) { |
|
| 25 | 25 | throw new InvalidArgumentException($status . ' is not valid validation result status'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function getValue(): mixed |
| 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 | $value = $this->isMulti() ? filter_input(INPUT_GET, $this->key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY) : filter_input(INPUT_GET, $this->key); |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | return new ValidationResult(ValidationResult::STATUS_ERROR, ['missing data']); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (!empty($this->rawInput) && json_last_error()) { |
|
| 49 | + if ( ! empty($this->rawInput) && json_last_error()) { |
|
| 50 | 50 | return new ValidationResult(ValidationResult::STATUS_ERROR, [json_last_error_msg()]); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if (!$value && $this->isRequired() === self::OPTIONAL) { |
|
| 53 | + if ( ! $value && $this->isRequired() === self::OPTIONAL) { |
|
| 54 | 54 | return new ValidationResult(ValidationResult::STATUS_OK); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $fullSchema = json_decode($this->schema, true); |
| 70 | 70 | |
| 71 | - if (!empty($examples = $this->getExamples())) { |
|
| 71 | + if ( ! empty($examples = $this->getExamples())) { |
|
| 72 | 72 | if (count($examples) === 1) { |
| 73 | 73 | $fullSchema['example'] = is_array($this->getExample()) ? $this->getExample() : json_decode($this->getExample(), true); |
| 74 | 74 | } else { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!empty($fullSchema['examples'])) { |
|
| 82 | + if ( ! empty($fullSchema['examples'])) { |
|
| 83 | 83 | $this->description .= <<< HTML |
| 84 | 84 | <div> |
| 85 | 85 | Select Example: |