Passed
Branch master (2c4e07)
by Marcin
03:58
created
src/ExceptionHandlerHelper.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 	 * @return HttpResponse
108 108
 	 */
109 109
 	protected static function error(Exception $exception, $exception_type, $default_api_code,
110
-	                                $default_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
110
+									$default_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
111 111
 	{
112 112
 		// common prefix for config key
113 113
 		$base_config = 'response_builder.exception_handler.exception';
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -149,7 +149,7 @@
 block discarded – undo
149 149
 		$data = null;
150 150
 		if ($api_code === Config::get("{$base_config}.validation_exception.code", BaseApiCodes::EX_VALIDATION_EXCEPTION())) {
151 151
 			/** @var ValidationException $exception */
152
-			$data = [ResponseBuilder::KEY_MESSAGES => $exception->validator->errors()->messages()];
152
+			$data = [ ResponseBuilder::KEY_MESSAGES => $exception->validator->errors()->messages() ];
153 153
 		}
154 154
 
155 155
 		$key = BaseApiCodes::getCodeMessageKey($api_code) ?? BaseApiCodes::getCodeMessageKey($base_api_code);
Please login to merge, or discard this patch.
src/ResponseBuilderServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	public function register()
34 34
 	{
35 35
 		$this->mergeConfigFrom(
36
-			__DIR__.'/../config/response_builder.php', 'response_builder'
36
+			__DIR__ . '/../config/response_builder.php', 'response_builder'
37 37
 		);
38 38
 	}
39 39
 
Please login to merge, or discard this patch.
src/ResponseBuilder.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 
108 108
 			$mandatory_keys = [static::KEY_KEY,
109
-			                   static::KEY_METHOD,
109
+							   static::KEY_METHOD,
110 110
 			];
111 111
 			foreach ($classes as $class_name => $class_config) {
112 112
 				foreach ($mandatory_keys as $key_name) {
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @throws \RuntimeException in case of missing or invalid "classes" mapping configuration
163 163
 	 */
164 164
 	protected static function buildResponse(bool $success, int $api_code, string $message, $data = null,
165
-	                                        array $debug_data = null): array
165
+											array $debug_data = null): array
166 166
 	{
167 167
 		// ensure data is serialized as object, not plain array, regardless what we are provided as argument
168 168
 		if ($data !== null) {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return HttpResponse
217 217
 	 */
218 218
 	public static function success($data = null, $api_code = null, array $lang_args = null,
219
-	                               int $http_code = null, int $encoding_options = null): HttpResponse
219
+								   int $http_code = null, int $encoding_options = null): HttpResponse
220 220
 	{
221 221
 		return static::buildSuccessResponse($data, $api_code, $lang_args, $http_code, $encoding_options);
222 222
 	}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @throws \InvalidArgumentException Thrown when provided arguments are invalid.
262 262
 	 */
263 263
 	protected static function buildSuccessResponse($data = null, int $api_code = null, array $lang_args = null,
264
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
264
+												   int $http_code = null, int $encoding_options = null): HttpResponse
265 265
 	{
266 266
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_OK;
267 267
 		$api_code = $api_code ?? BaseApiCodes::OK();
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @return HttpResponse
288 288
 	 */
289 289
 	public static function error(int $api_code, array $lang_args = null, $data = null, int $http_code = null,
290
-	                             int $encoding_options = null): HttpResponse
290
+								 int $encoding_options = null): HttpResponse
291 291
 	{
292 292
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
293 293
 	}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @return HttpResponse
302 302
 	 */
303 303
 	public static function errorWithData(int $api_code, $data, array $lang_args = null,
304
-	                                     int $encoding_options = null): HttpResponse
304
+										 int $encoding_options = null): HttpResponse
305 305
 	{
306 306
 		return static::buildErrorResponse($data, $api_code, null, $lang_args, $encoding_options);
307 307
 	}
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @throws \InvalidArgumentException if http_code is @null
319 319
 	 */
320 320
 	public static function errorWithDataAndHttpCode(int $api_code, $data, int $http_code, array $lang_args = null,
321
-	                                                int $encoding_options = null): HttpResponse
321
+													int $encoding_options = null): HttpResponse
322 322
 	{
323 323
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
324 324
 	}
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @return HttpResponse
348 348
 	 */
349 349
 	public static function errorWithMessageAndData(int $api_code, string $error_message, $data,
350
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
350
+												   int $http_code = null, int $encoding_options = null): HttpResponse
351 351
 	{
352 352
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
353 353
 			$error_message, null, $encoding_options);
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	 * @return HttpResponse
365 365
 	 */
366 366
 	public static function errorWithMessageAndDataAndDebug(int $api_code, string $error_message, $data,
367
-	                                                       int $http_code = null, int $encoding_options = null,
368
-	                                                       array $debug_data = null): HttpResponse
367
+														   int $http_code = null, int $encoding_options = null,
368
+														   array $debug_data = null): HttpResponse
369 369
 	{
370 370
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
371 371
 			$error_message, null, $encoding_options, $debug_data);
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @noinspection MoreThanThreeArgumentsInspection
405 405
 	 */
406 406
 	protected static function buildErrorResponse($data, int $api_code, int $http_code = null, array $lang_args = null,
407
-	                                             string $message = null, array $headers = null, int $encoding_options = null,
408
-	                                             array $debug_data = null): HttpResponse
407
+												 string $message = null, array $headers = null, int $encoding_options = null,
408
+												 array $debug_data = null): HttpResponse
409 409
 	{
410 410
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR;
411 411
 		$headers = $headers ?? [];
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @noinspection MoreThanThreeArgumentsInspection
445 445
 	 */
446 446
 	protected static function make(bool $success, int $api_code, $message_or_api_code, $data = null,
447
-	                               int $http_code = null, array $lang_args = null, array $headers = null,
448
-	                               int $encoding_options = null, array $debug_data = null): HttpResponse
447
+								   int $http_code = null, array $lang_args = null, array $headers = null,
448
+								   int $encoding_options = null, array $debug_data = null): HttpResponse
449 449
 	{
450 450
 		$headers = $headers ?? [];
451 451
 		$http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 					sprintf('CONFIG: "classes" mapping must be an array (%s given)', gettype($classes)));
106 106
 			}
107 107
 
108
-			$mandatory_keys = [static::KEY_KEY,
108
+			$mandatory_keys = [ static::KEY_KEY,
109 109
 			                   static::KEY_METHOD,
110 110
 			];
111 111
 			foreach ($classes as $class_name => $class_config) {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 					$obj_class_name = get_class($data);
177 177
 					if (array_key_exists($obj_class_name, $classes)) {
178 178
 						$conversion_method = $classes[ $obj_class_name ][ static::KEY_METHOD ];
179
-						$data = [$classes[ $obj_class_name ][ static::KEY_KEY ] => $data->$conversion_method()];
179
+						$data = [ $classes[ $obj_class_name ][ static::KEY_KEY ] => $data->$conversion_method() ];
180 180
 					}
181 181
 				}
182 182
 			}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
 		if ($data !== null) {
186 186
 			// ensure we get object in final JSON structure in data node
187
-			$data = (object)$data;
187
+			$data = (object) $data;
188 188
 		}
189 189
 
190 190
 		$response = [
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	public static function successWithHttpCode(int $http_code = null): HttpResponse
247 247
 	{
248
-		return static::buildSuccessResponse(null, BaseApiCodes::OK(), [], $http_code);
248
+		return static::buildSuccessResponse(null, BaseApiCodes::OK(), [ ], $http_code);
249 249
 	}
250 250
 
251 251
 	/**
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	                                             array $debug_data = null): HttpResponse
409 409
 	{
410 410
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR;
411
-		$headers = $headers ?? [];
411
+		$headers = $headers ?? [ ];
412 412
 
413 413
 		Validator::assertInt('api_code', $api_code);
414 414
 		Validator::assertIntRange('api_code', $api_code, BaseApiCodes::getMinCode(), BaseApiCodes::getMaxCode());
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	                               int $http_code = null, array $lang_args = null, array $headers = null,
448 448
 	                               int $encoding_options = null, array $debug_data = null): HttpResponse
449 449
 	{
450
-		$headers = $headers ?? [];
450
+		$headers = $headers ?? [ ];
451 451
 		$http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR);
452 452
 		$encoding_options = $encoding_options ?? Config::get(self::CONF_KEY_ENCODING_OPTIONS, static::DEFAULT_ENCODING_OPTIONS);
453 453
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 				// nope, let's get the default one instead
476 476
 				$key = BaseApiCodes::getCodeMessageKey($success ? BaseApiCodes::OK() : BaseApiCodes::NO_ERROR_MESSAGE());
477 477
 			}
478
-			$lang_args = $lang_args ?? ['api_code' => $message_or_api_code];
478
+			$lang_args = $lang_args ?? [ 'api_code' => $message_or_api_code ];
479 479
 			$message_or_api_code = \Lang::get($key, $lang_args);
480 480
 		}
481 481
 
Please login to merge, or discard this patch.