Completed
Pull Request — master (#104)
by Marcin
05:28 queued 02:27
created
src/ExceptionHandlerHelper.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return HttpResponse
95 95
 	 */
96 96
 	protected function unauthenticated(/** @scrutinizer ignore-unused */ $request,
97
-	                                                                     AuthenticationException $exception): HttpResponse
97
+																		 AuthenticationException $exception): HttpResponse
98 98
 	{
99 99
 		return static::error($exception, 'authentication_exception', BaseApiCodes::EX_AUTHENTICATION_EXCEPTION());
100 100
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @return HttpResponse
111 111
 	 */
112 112
 	protected static function error(Exception $exception, $exception_config_key, $fallback_api_code,
113
-	                                $fallback_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
113
+									$fallback_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
114 114
 	{
115 115
 		// common prefix for config key
116 116
 		$base_key = sprintf('%s.exception', ResponseBuilder::CONF_EXCEPTION_HANDLER_KEY);
Please login to merge, or discard this patch.
src/Converter.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		// check for exact class name match...
73 73
 		$cls = get_class($data);
74 74
 		if (array_key_exists($cls, $this->classes)) {
75
-			$result = $this->classes[ $cls ];
75
+			$result = $this->classes[$cls];
76 76
 		} else {
77 77
 			// no exact match, then lets try with `instanceof`
78 78
 			foreach (array_keys($this->classes) as $class_name) {
79 79
 				if ($data instanceof $class_name) {
80
-					$result = $this->classes[ $class_name ];
80
+					$result = $this->classes[$class_name];
81 81
 					break;
82 82
 				}
83 83
 			}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 		if (is_object($data)) {
109 109
 			$cfg = $this->getClassMappingConfigOrThrow($data);
110
-			$data = [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()];
110
+			$data = [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()];
111 111
 		} elseif (!is_array($data)) {
112 112
 			throw new \InvalidArgumentException(
113 113
 				sprintf('Payload must be null, array or object with mapping ("%s" given).', gettype($data)));
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
 		foreach ($data as $key => $val) {
151 151
 			if (is_array($val)) {
152
-				$data[ $key ] = $this->convertArray($val);
152
+				$data[$key] = $this->convertArray($val);
153 153
 			} elseif (is_object($val)) {
154 154
 				$cls = get_class($val);
155 155
 				if (array_key_exists($cls, $this->classes)) {
156
-					$conversion_method = $this->classes[ $cls ][ ResponseBuilder::KEY_METHOD ];
156
+					$conversion_method = $this->classes[$cls][ResponseBuilder::KEY_METHOD];
157 157
 					$converted_data = $val->$conversion_method();
158
-					$data[ $key ] = $converted_data;
158
+					$data[$key] = $converted_data;
159 159
 				}
160 160
 			}
161 161
 		}
Please login to merge, or discard this patch.
src/ResponseBuilder.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		$data = $converter->convert($data);
492 492
 		if ($data !== null && !is_object($data)) {
493 493
 			// ensure we get object in final JSON structure in data node
494
-			$data = (object)$data;
494
+			$data = (object) $data;
495 495
 		}
496 496
 
497 497
 		// get human readable message for API code or use message string (if given instead of API code)
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 
514 514
 		if ($debug_data !== null) {
515 515
 			$debug_key = Config::get(static::CONF_KEY_DEBUG_DEBUG_KEY, self::KEY_DEBUG);
516
-			$response[ $debug_key ] = $debug_data;
516
+			$response[$debug_key] = $debug_data;
517 517
 		}
518 518
 
519 519
 		return $response;
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return HttpResponse
154 154
 	 */
155 155
 	public static function success($data = null, $api_code = null, array $placeholders = null,
156
-	                               int $http_code = null, int $json_opts = null): HttpResponse
156
+								   int $http_code = null, int $json_opts = null): HttpResponse
157 157
 	{
158 158
 		return static::buildSuccessResponse($data, $api_code, $placeholders, $http_code, $json_opts);
159 159
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @return HttpResponse
171 171
 	 */
172 172
 	public static function successWithCode(int $api_code = null, array $placeholders = null,
173
-	                                       int $http_code = null): HttpResponse
173
+										   int $http_code = null): HttpResponse
174 174
 	{
175 175
 		return static::success(null, $api_code, $placeholders, $http_code);
176 176
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @throws \InvalidArgumentException Thrown when provided arguments are invalid.
206 206
 	 */
207 207
 	protected static function buildSuccessResponse($data = null, int $api_code = null, array $placeholders = null,
208
-	                                               int $http_code = null, int $json_opts = null): HttpResponse
208
+												   int $http_code = null, int $json_opts = null): HttpResponse
209 209
 	{
210 210
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_OK;
211 211
 		$api_code = $api_code ?? BaseApiCodes::OK();
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @return HttpResponse
236 236
 	 */
237 237
 	public static function error(int $api_code, array $placeholders = null, $data = null, int $http_code = null,
238
-	                             int $encoding_options = null): HttpResponse
238
+								 int $encoding_options = null): HttpResponse
239 239
 	{
240 240
 		return static::buildErrorResponse($data, $api_code, $http_code, $placeholders, $encoding_options);
241 241
 	}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return HttpResponse
254 254
 	 */
255 255
 	public static function errorWithData(int $api_code, $data, array $placeholders = null,
256
-	                                     int $json_opts = null): HttpResponse
256
+										 int $json_opts = null): HttpResponse
257 257
 	{
258 258
 		return static::buildErrorResponse($data, $api_code, null, $placeholders, $json_opts);
259 259
 	}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @throws \InvalidArgumentException if http_code is @null
275 275
 	 */
276 276
 	public static function errorWithDataAndHttpCode(int $api_code, $data, int $http_code, array $placeholders = null,
277
-	                                                int $json_opts = null): HttpResponse
277
+													int $json_opts = null): HttpResponse
278 278
 	{
279 279
 		return static::buildErrorResponse($data, $api_code, $http_code, $placeholders, $json_opts);
280 280
 	}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return HttpResponse
310 310
 	 */
311 311
 	public static function errorWithMessageAndData(int $api_code, string $message, $data,
312
-	                                               int $http_code = null, int $json_opts = null): HttpResponse
312
+												   int $http_code = null, int $json_opts = null): HttpResponse
313 313
 	{
314 314
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
315 315
 			$message, null, $json_opts);
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
 	 * @return HttpResponse
331 331
 	 */
332 332
 	public static function errorWithMessageAndDataAndDebug(int $api_code, string $message, $data,
333
-	                                                       int $http_code = null, int $json_opts = null,
334
-	                                                       array $debug_data = null): HttpResponse
333
+														   int $http_code = null, int $json_opts = null,
334
+														   array $debug_data = null): HttpResponse
335 335
 	{
336 336
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
337 337
 			$message, null, $json_opts, $debug_data);
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
 	 * @noinspection MoreThanThreeArgumentsInspection
376 376
 	 */
377 377
 	protected static function buildErrorResponse($data, int $api_code, int $http_code = null,
378
-	                                             array $placeholders = null,
379
-	                                             string $message = null, array $headers = null,
380
-	                                             int $json_opts = null,
381
-	                                             array $debug_data = null): HttpResponse
378
+												 array $placeholders = null,
379
+												 string $message = null, array $headers = null,
380
+												 int $json_opts = null,
381
+												 array $debug_data = null): HttpResponse
382 382
 	{
383 383
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR;
384 384
 		$headers = $headers ?? [];
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @noinspection MoreThanThreeArgumentsInspection
426 426
 	 */
427 427
 	protected static function make(bool $success, int $api_code, $msg_or_api_code, $data = null,
428
-	                               int $http_code = null, array $placeholders = null, array $headers = null,
429
-	                               int $json_opts = null, array $debug_data = null): HttpResponse
428
+								   int $http_code = null, array $placeholders = null, array $headers = null,
429
+								   int $json_opts = null, array $debug_data = null): HttpResponse
430 430
 	{
431 431
 		$headers = $headers ?? [];
432 432
 		$http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR);
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
 	 * @throws \RuntimeException in case of missing or invalid "classes" mapping configuration
497 497
 	 */
498 498
 	protected static function buildResponse(bool $success, int $api_code,
499
-	                                        $msg_or_api_code, array $placeholders = null,
500
-	                                        $data = null, array $debug_data = null): array
499
+											$msg_or_api_code, array $placeholders = null,
500
+											$data = null, array $debug_data = null): array
501 501
 	{
502 502
 		// ensure $data is either @null, array or object of class with configured mapping.
503 503
 		$converter = new Converter();
Please login to merge, or discard this patch.