Completed
Pull Request — master (#80)
by Michal
01:39
created
src/ValidationResult/ValidationResult.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Params/ParamsProcessor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Params/JsonInputParam.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Output/JsonOutput.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
     public function validate(ResponseInterface $response): ValidationResultInterface
27 27
     {
28
-        if (!$response instanceof JsonApiResponse) {
28
+        if ( ! $response instanceof JsonApiResponse) {
29 29
             return new ValidationResult(ValidationResult::STATUS_ERROR);
30 30
         }
31 31
         if ($this->code !== $response->getCode()) {
Please login to merge, or discard this patch.
src/Misc/ConsoleRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@
 block discarded – undo
205 205
     {
206 206
         $result = [];
207 207
         foreach ($values as $key => $value) {
208
-            if (!is_array($value)) {
208
+            if ( ! is_array($value)) {
209 209
                 $result[$key] = $value;
210 210
                 continue;
211 211
             }
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(500, ['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
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse
154 154
     {
155 155
         $rateLimitResponse = $rateLimit->check();
156
-        if (!$rateLimitResponse) {
156
+        if ( ! $rateLimitResponse) {
157 157
             return null;
158 158
         }
159 159
 
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
         $remaining = $rateLimitResponse->getRemaining();
162 162
         $retryAfter = $rateLimitResponse->getRetryAfter();
163 163
 
164
-        $this->response->addHeader('X-RateLimit-Limit', (string)$limit);
165
-        $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining);
164
+        $this->response->addHeader('X-RateLimit-Limit', (string) $limit);
165
+        $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining);
166 166
 
167 167
         if ($remaining === 0) {
168 168
             $this->response->setCode(Response::S429_TOO_MANY_REQUESTS);
169
-            $this->response->addHeader('Retry-After', (string)$retryAfter);
169
+            $this->response->addHeader('Retry-After', (string) $retryAfter);
170 170
             return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']);
171 171
         }
172 172
         return null;
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 
229 229
     private function getRequestDomain(): ?string
230 230
     {
231
-        if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
231
+        if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
232 232
             return null;
233 233
         }
234 234
         $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER'));
235
-        if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
235
+        if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
236 236
             return null;
237 237
         }
238 238
         $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host'];
Please login to merge, or discard this patch.