@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | private function getApiList(int $version): array |
| 55 | 55 | { |
| 56 | - $versionApis = array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) { |
|
| 56 | + $versionApis = array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) { |
|
| 57 | 57 | return $version === $api->getEndpoint()->getVersion(); |
| 58 | 58 | }); |
| 59 | 59 | |
| 60 | - return array_map(function (Api $api) { |
|
| 60 | + return array_map(function(Api $api) { |
|
| 61 | 61 | return [ |
| 62 | 62 | 'method' => $api->getEndpoint()->getMethod(), |
| 63 | 63 | 'version' => $api->getEndpoint()->getVersion(), |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | private function createParamsList(ApiHandlerInterface $handler): array |
| 81 | 81 | { |
| 82 | - return array_map(function (InputParam $param) { |
|
| 82 | + return array_map(function(InputParam $param) { |
|
| 83 | 83 | $parameter = [ |
| 84 | 84 | 'type' => $param->getType(), |
| 85 | 85 | 'key' => $param->getKey(), |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $result = $this->tokenRepository->validToken($token); |
| 48 | - if (!$result) { |
|
| 48 | + if ( ! $result) { |
|
| 49 | 49 | $this->errorMessage = 'Token doesn\'t exists or isn\'t active'; |
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if (!$this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
| 53 | + if ( ! $this->isValidIp($this->tokenRepository->ipRestrictions($token))) { |
|
| 54 | 54 | $this->errorMessage = 'Invalid IP'; |
| 55 | 55 | return false; |
| 56 | 56 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | list($range, $netmask) = explode('/', $range, 2); |
| 114 | 114 | $range_decimal = ip2long($range); |
| 115 | 115 | $ipDecimal = ip2long($ip); |
| 116 | - $wildcard_decimal = pow(2, (32 - (int)$netmask)) - 1; |
|
| 116 | + $wildcard_decimal = pow(2, (32 - (int) $netmask)) - 1; |
|
| 117 | 117 | $netmask_decimal = ~ $wildcard_decimal; |
| 118 | 118 | return (($ipDecimal & $netmask_decimal) === ($range_decimal & $netmask_decimal)); |
| 119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | private function readAuthorizationToken(): ?string |
| 128 | 128 | { |
| 129 | - if (!isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
| 129 | + if ( ! isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
| 130 | 130 | $this->errorMessage = 'Authorization header HTTP_Authorization is not set'; |
| 131 | 131 | return null; |
| 132 | 132 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function __construct(string $status, array $errors = []) |
| 18 | 18 | { |
| 19 | - if (!in_array($status, [self::STATUS_OK, self::STATUS_ERROR], true)) { |
|
| 19 | + if ( ! in_array($status, [self::STATUS_OK, self::STATUS_ERROR], true)) { |
|
| 20 | 20 | throw new InvalidArgumentException($status . ' is not valid validation result status'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -21,11 +21,11 @@ |
||
| 21 | 21 | { |
| 22 | 22 | foreach ($this->params as $param) { |
| 23 | 23 | $validationResult = $param->validate(); |
| 24 | - if (!$validationResult->isOk()) { |
|
| 24 | + if ( ! $validationResult->isOk()) { |
|
| 25 | 25 | $this->errors[$param->getKey()] = $validationResult->getErrors(); |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | - return !empty($this->errors); |
|
| 28 | + return ! empty($this->errors); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function getErrors(): array |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | return new ValidationResult(ValidationResult::STATUS_ERROR, [json_last_error_msg()]); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if (!$value && $this->isRequired() === self::OPTIONAL) { |
|
| 43 | + if ( ! $value && $this->isRequired() === self::OPTIONAL) { |
|
| 44 | 44 | return new ValidationResult(ValidationResult::STATUS_OK); |
| 45 | 45 | } |
| 46 | 46 | |