Completed
Branch dev (fcb395)
by Marcin
06:22 queued 03:31
created
src/ExceptionHandlerHelper.php 1 patch
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.
src/ResponseBuilderServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@
 block discarded – undo
92 92
 			if (is_numeric($key)) {
93 93
 				continue;
94 94
 			}
95
-			$array[ $key ] = $this->mergeConfig($value, $merging[ $key ]);
95
+			$array[$key] = $this->mergeConfig($value, $merging[$key]);
96 96
 		}
97 97
 
98 98
 		return $array;
Please login to merge, or discard this patch.
src/ApiCodesHelpers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
 
113 113
 		$map = static::getMap();
114 114
 
115
-		return $map[ $api_code ] ?? null;
115
+		return $map[$api_code] ?? null;
116 116
 	}
117 117
 
118 118
 	public static function isCodeValid($code): bool
Please login to merge, or discard this patch.
src/ResponseBuilder.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @return HttpResponse
137 137
 	 */
138 138
 	public static function success($data = null, $api_code = null, array $lang_args = null,
139
-	                               int $http_code = null, int $encoding_options = null): HttpResponse
139
+								   int $http_code = null, int $encoding_options = null): HttpResponse
140 140
 	{
141 141
 		return static::buildSuccessResponse($data, $api_code, $lang_args, $http_code, $encoding_options);
142 142
 	}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @throws \InvalidArgumentException Thrown when provided arguments are invalid.
182 182
 	 */
183 183
 	protected static function buildSuccessResponse($data = null, int $api_code = null, array $lang_args = null,
184
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
184
+												   int $http_code = null, int $encoding_options = null): HttpResponse
185 185
 	{
186 186
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_OK;
187 187
 		$api_code = $api_code ?? BaseApiCodes::OK();
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * @return HttpResponse
208 208
 	 */
209 209
 	public static function error(int $api_code, array $lang_args = null, $data = null, int $http_code = null,
210
-	                             int $encoding_options = null): HttpResponse
210
+								 int $encoding_options = null): HttpResponse
211 211
 	{
212 212
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
213 213
 	}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @return HttpResponse
223 223
 	 */
224 224
 	public static function errorWithData(int $api_code, $data, array $lang_args = null,
225
-	                                     int $encoding_options = null): HttpResponse
225
+										 int $encoding_options = null): HttpResponse
226 226
 	{
227 227
 		return static::buildErrorResponse($data, $api_code, null, $lang_args, $encoding_options);
228 228
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @throws \InvalidArgumentException if http_code is @null
241 241
 	 */
242 242
 	public static function errorWithDataAndHttpCode(int $api_code, $data, int $http_code, array $lang_args = null,
243
-	                                                int $encoding_options = null): HttpResponse
243
+													int $encoding_options = null): HttpResponse
244 244
 	{
245 245
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
246 246
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return HttpResponse
271 271
 	 */
272 272
 	public static function errorWithMessageAndData(int $api_code, string $error_message, $data,
273
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
273
+												   int $http_code = null, int $encoding_options = null): HttpResponse
274 274
 	{
275 275
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
276 276
 			$error_message, null, $encoding_options);
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 * @return HttpResponse
289 289
 	 */
290 290
 	public static function errorWithMessageAndDataAndDebug(int $api_code, string $error_message, $data,
291
-	                                                       int $http_code = null, int $encoding_options = null,
292
-	                                                       array $debug_data = null): HttpResponse
291
+														   int $http_code = null, int $encoding_options = null,
292
+														   array $debug_data = null): HttpResponse
293 293
 	{
294 294
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
295 295
 			$error_message, null, $encoding_options, $debug_data);
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * @noinspection MoreThanThreeArgumentsInspection
329 329
 	 */
330 330
 	protected static function buildErrorResponse($data, int $api_code, int $http_code = null, array $lang_args = null,
331
-	                                             string $message = null, array $headers = null, int $encoding_options = null,
332
-	                                             array $debug_data = null): HttpResponse
331
+												 string $message = null, array $headers = null, int $encoding_options = null,
332
+												 array $debug_data = null): HttpResponse
333 333
 	{
334 334
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR;
335 335
 		$headers = $headers ?? [];
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @noinspection MoreThanThreeArgumentsInspection
373 373
 	 */
374 374
 	protected static function make(bool $success, int $api_code, $message_or_api_code, $data = null,
375
-	                               int $http_code = null, array $lang_args = null, array $headers = null,
376
-	                               int $encoding_options = null, array $debug_data = null): HttpResponse
375
+								   int $http_code = null, array $lang_args = null, array $headers = null,
376
+								   int $encoding_options = null, array $debug_data = null): HttpResponse
377 377
 	{
378 378
 		$headers = $headers ?? [];
379 379
 		$http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR);
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @throws \RuntimeException in case of missing or invalid "classes" mapping configuration
430 430
 	 */
431 431
 	protected static function buildResponse(bool $success, int $api_code, string $message, $data = null,
432
-	                                        array $debug_data = null): array
432
+											array $debug_data = null): array
433 433
 	{
434 434
 		// ensure $data is either @null, array or object of class with configured mapping.
435 435
 		$converter = new Converter();
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		$data = $converter->convert($data);
438 438
 		if ($data !== null && !is_object($data)) {
439 439
 			// ensure we get object in final JSON structure in data node
440
-			$data = (object)$data;
440
+			$data = (object) $data;
441 441
 		}
442 442
 
443 443
 		/** @noinspection PhpUndefinedClassInspection */
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 
452 452
 		if ($debug_data !== null) {
453 453
 			$debug_key = Config::get(static::CONF_KEY_DEBUG_DEBUG_KEY, self::KEY_DEBUG);
454
-			$response[ $debug_key ] = $debug_data;
454
+			$response[$debug_key] = $debug_data;
455 455
 		}
456 456
 
457 457
 		return $response;
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
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 		// check for exact class name match...
57 57
 		$cls = get_class($data);
58 58
 		if (array_key_exists($cls, $this->classes)) {
59
-			$result = $this->classes[ $cls ];
59
+			$result = $this->classes[$cls];
60 60
 		} else {
61 61
 			// no exact match, then lets try with `instanceof`
62 62
 			foreach ($this->classes as $class_name => $params) {
63 63
 				if ($data instanceof $class_name) {
64
-					$result = $this->classes[ $class_name ];
64
+					$result = $this->classes[$class_name];
65 65
 					break;
66 66
 				}
67 67
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		if (is_object($data)) {
91 91
 			$cfg = $this->getClassMappingConfigOrThrow($data);
92
-			$data = [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()];
92
+			$data = [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()];
93 93
 		} elseif (!is_array($data)) {
94 94
 			throw new \InvalidArgumentException(
95 95
 				sprintf('Invalid payload data. Must be null, array or object with mapping ("%s" given).', gettype($data)));
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 
130 130
 		foreach ($data as $key => $val) {
131 131
 			if (is_array($val)) {
132
-				$data[ $key ] = $this->convertArray($val);
132
+				$data[$key] = $this->convertArray($val);
133 133
 			} elseif (is_object($val)) {
134 134
 				$cls = get_class($val);
135 135
 				$cfg = $this->getClassMappingConfigOrThrow($val);
136 136
 				if (array_key_exists($cls, $this->classes)) {
137
-					$conversion_method = $this->classes[ $cls ][ ResponseBuilder::KEY_METHOD ];
137
+					$conversion_method = $this->classes[$cls][ResponseBuilder::KEY_METHOD];
138 138
 					$converted_data = $val->$conversion_method();
139 139
 //							$data = [$this->classes[ $cls ][ ResponseBuilder::KEY_KEY ] => $converted_data];
140
-					$data[ $key ] = $converted_data;
140
+					$data[$key] = $converted_data;
141 141
 				}
142 142
 			}
143 143
 		}
Please login to merge, or discard this patch.