Completed
Push — master ( ac4e13...d4f3ab )
by Tomas
20s queued 14s
created
src/Presenters/ApiPresenter.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,15 +108,15 @@  discard block
 block discarded – undo
108 108
                 }
109 109
                 $outputValidatorErrors[] = $validationResult->getErrors();
110 110
             }
111
-            if (!$outputValid) {
111
+            if ( ! $outputValid) {
112 112
                 Debugger::log($outputValidatorErrors, Debugger::ERROR);
113
-                if (!Debugger::$productionMode) {
113
+                if ( ! Debugger::$productionMode) {
114 114
                     $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'details' => $outputValidatorErrors]);
115 115
                 }
116 116
             }
117 117
             $code = $response->getCode();
118 118
         } catch (Throwable $exception) {
119
-            if (!Debugger::$productionMode) {
119
+            if ( ! Debugger::$productionMode) {
120 120
                 $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error', 'detail' => $exception->getMessage()]);
121 121
             } else {
122 122
                 $response = new JsonApiResponse(Response::S500_INTERNAL_SERVER_ERROR, ['status' => 'error', 'message' => 'Internal server error']);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     private function checkAuth(ApiAuthorizationInterface $authorization): ?IResponse
152 152
     {
153
-        if (!$authorization->authorized()) {
153
+        if ( ! $authorization->authorized()) {
154 154
             $this->response->setCode(Response::S403_FORBIDDEN);
155 155
             return new JsonResponse(['status' => 'error', 'message' => $authorization->getErrorMessage()]);
156 156
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     private function checkRateLimit(RateLimitInterface $rateLimit): ?IResponse
161 161
     {
162 162
         $rateLimitResponse = $rateLimit->check();
163
-        if (!$rateLimitResponse) {
163
+        if ( ! $rateLimitResponse) {
164 164
             return null;
165 165
         }
166 166
 
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
         $remaining = $rateLimitResponse->getRemaining();
169 169
         $retryAfter = $rateLimitResponse->getRetryAfter();
170 170
 
171
-        $this->response->addHeader('X-RateLimit-Limit', (string)$limit);
172
-        $this->response->addHeader('X-RateLimit-Remaining', (string)$remaining);
171
+        $this->response->addHeader('X-RateLimit-Limit', (string) $limit);
172
+        $this->response->addHeader('X-RateLimit-Remaining', (string) $remaining);
173 173
 
174 174
         if ($remaining === 0) {
175 175
             $this->response->setCode(Response::S429_TOO_MANY_REQUESTS);
176
-            $this->response->addHeader('Retry-After', (string)$retryAfter);
176
+            $this->response->addHeader('Retry-After', (string) $retryAfter);
177 177
             return $rateLimitResponse->getErrorResponse() ?: new JsonResponse(['status' => 'error', 'message' => 'Too many requests. Retry after ' . $retryAfter . ' seconds.']);
178 178
         }
179 179
         return null;
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 
236 236
     private function getRequestDomain(): ?string
237 237
     {
238
-        if (!filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
238
+        if ( ! filter_input(INPUT_SERVER, 'HTTP_REFERER')) {
239 239
             return null;
240 240
         }
241 241
         $refererParsedUrl = parse_url(filter_input(INPUT_SERVER, 'HTTP_REFERER'));
242
-        if (!(isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
242
+        if ( ! (isset($refererParsedUrl['scheme']) && isset($refererParsedUrl['host']))) {
243 243
             return null;
244 244
         }
245 245
         $url = $refererParsedUrl['scheme'] . '://' . $refererParsedUrl['host'];
Please login to merge, or discard this patch.