Passed
Pull Request — dev (#103)
by Marcin
02:57
created
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/Converter.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 		// check for exact class name match...
70 70
 		$cls = get_class($data);
71 71
 		if (array_key_exists($cls, $this->classes)) {
72
-			$result = $this->classes[ $cls ];
72
+			$result = $this->classes[$cls];
73 73
 		} else {
74 74
 			// no exact match, then lets try with `instanceof`
75 75
 			foreach (array_keys($this->classes) as $class_name) {
76 76
 				if ($data instanceof $class_name) {
77
-					$result = $this->classes[ $class_name ];
77
+					$result = $this->classes[$class_name];
78 78
 					break;
79 79
 				}
80 80
 			}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
 		if (is_object($data)) {
104 104
 			$cfg = $this->getClassMappingConfigOrThrow($data);
105
-			$data = [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()];
105
+			$data = [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()];
106 106
 		} elseif (!is_array($data)) {
107 107
 			throw new \InvalidArgumentException(
108 108
 				sprintf('Invalid payload data. Must be null, array or object with mapping ("%s" given).', gettype($data)));
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 
143 143
 		foreach ($data as $key => $val) {
144 144
 			if (is_array($val)) {
145
-				$data[ $key ] = $this->convertArray($val);
145
+				$data[$key] = $this->convertArray($val);
146 146
 			} elseif (is_object($val)) {
147 147
 				$cls = get_class($val);
148 148
 				if (array_key_exists($cls, $this->classes)) {
149
-					$conversion_method = $this->classes[ $cls ][ ResponseBuilder::KEY_METHOD ];
149
+					$conversion_method = $this->classes[$cls][ResponseBuilder::KEY_METHOD];
150 150
 					$converted_data = $val->$conversion_method();
151
-					$data[ $key ] = $converted_data;
151
+					$data[$key] = $converted_data;
152 152
 				}
153 153
 			}
154 154
 		}
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
 	/**
Please login to merge, or discard this patch.
src/ExceptionHandlerHelper.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
 	 * @return HttpResponse
110 110
 	 */
111 111
 	protected static function error(Exception $exception, $exception_config_key, $fallback_api_code,
112
-	                                $fallback_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
112
+									$fallback_http_code = ResponseBuilder::DEFAULT_HTTP_CODE_ERROR): HttpResponse
113 113
 	{
114 114
 		// common prefix for config key
115 115
 		$base_config_key = sprintf('%s.exception', ResponseBuilder::CONF_EXCEPTION_HANDLER_KEY);
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
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return HttpResponse
138 138
 	 */
139 139
 	public static function success($data = null, $api_code = null, array $lang_args = null,
140
-	                               int $http_code = null, int $encoding_options = null): HttpResponse
140
+								   int $http_code = null, int $encoding_options = null): HttpResponse
141 141
 	{
142 142
 		return static::buildSuccessResponse($data, $api_code, $lang_args, $http_code, $encoding_options);
143 143
 	}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @throws \InvalidArgumentException Thrown when provided arguments are invalid.
183 183
 	 */
184 184
 	protected static function buildSuccessResponse($data = null, int $api_code = null, array $lang_args = null,
185
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
185
+												   int $http_code = null, int $encoding_options = null): HttpResponse
186 186
 	{
187 187
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_OK;
188 188
 		$api_code = $api_code ?? BaseApiCodes::OK();
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return HttpResponse
209 209
 	 */
210 210
 	public static function error(int $api_code, array $lang_args = null, $data = null, int $http_code = null,
211
-	                             int $encoding_options = null): HttpResponse
211
+								 int $encoding_options = null): HttpResponse
212 212
 	{
213 213
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
214 214
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return HttpResponse
224 224
 	 */
225 225
 	public static function errorWithData(int $api_code, $data, array $lang_args = null,
226
-	                                     int $encoding_options = null): HttpResponse
226
+										 int $encoding_options = null): HttpResponse
227 227
 	{
228 228
 		return static::buildErrorResponse($data, $api_code, null, $lang_args, $encoding_options);
229 229
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @throws \InvalidArgumentException if http_code is @null
242 242
 	 */
243 243
 	public static function errorWithDataAndHttpCode(int $api_code, $data, int $http_code, array $lang_args = null,
244
-	                                                int $encoding_options = null): HttpResponse
244
+													int $encoding_options = null): HttpResponse
245 245
 	{
246 246
 		return static::buildErrorResponse($data, $api_code, $http_code, $lang_args, $encoding_options);
247 247
 	}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @return HttpResponse
272 272
 	 */
273 273
 	public static function errorWithMessageAndData(int $api_code, string $error_message, $data,
274
-	                                               int $http_code = null, int $encoding_options = null): HttpResponse
274
+												   int $http_code = null, int $encoding_options = null): HttpResponse
275 275
 	{
276 276
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
277 277
 			$error_message, null, $encoding_options);
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @return HttpResponse
290 290
 	 */
291 291
 	public static function errorWithMessageAndDataAndDebug(int $api_code, string $error_message, $data,
292
-	                                                       int $http_code = null, int $encoding_options = null,
293
-	                                                       array $debug_data = null): HttpResponse
292
+														   int $http_code = null, int $encoding_options = null,
293
+														   array $debug_data = null): HttpResponse
294 294
 	{
295 295
 		return static::buildErrorResponse($data, $api_code, $http_code, null,
296 296
 			$error_message, null, $encoding_options, $debug_data);
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @noinspection MoreThanThreeArgumentsInspection
330 330
 	 */
331 331
 	protected static function buildErrorResponse($data, int $api_code, int $http_code = null, array $lang_args = null,
332
-	                                             string $message = null, array $headers = null, int $encoding_options = null,
333
-	                                             array $debug_data = null): HttpResponse
332
+												 string $message = null, array $headers = null, int $encoding_options = null,
333
+												 array $debug_data = null): HttpResponse
334 334
 	{
335 335
 		$http_code = $http_code ?? static::DEFAULT_HTTP_CODE_ERROR;
336 336
 		$headers = $headers ?? [];
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @noinspection MoreThanThreeArgumentsInspection
374 374
 	 */
375 375
 	protected static function make(bool $success, int $api_code, $message_or_api_code, $data = null,
376
-	                               int $http_code = null, array $lang_args = null, array $headers = null,
377
-	                               int $encoding_options = null, array $debug_data = null): HttpResponse
376
+								   int $http_code = null, array $lang_args = null, array $headers = null,
377
+								   int $encoding_options = null, array $debug_data = null): HttpResponse
378 378
 	{
379 379
 		$headers = $headers ?? [];
380 380
 		$http_code = $http_code ?? ($success ? static::DEFAULT_HTTP_CODE_OK : static::DEFAULT_HTTP_CODE_ERROR);
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @throws \RuntimeException in case of missing or invalid "classes" mapping configuration
442 442
 	 */
443 443
 	protected static function buildResponse(bool $success, int $api_code,
444
-	                                        $message_or_api_code, array $lang_args = null,
445
-	                                        $data = null, array $debug_data = null): array
444
+											$message_or_api_code, array $lang_args = null,
445
+											$data = null, array $debug_data = null): array
446 446
 	{
447 447
 		// ensure $data is either @null, array or object of class with configured mapping.
448 448
 		$converter = new Converter();
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		$data = $converter->convert($data);
451 451
 		if ($data !== null && !is_object($data)) {
452 452
 			// ensure we get object in final JSON structure in data node
453
-			$data = (object)$data;
453
+			$data = (object) $data;
454 454
 		}
455 455
 
456 456
 		$lang_args = $lang_args ?? [];
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
 		if ($debug_data !== null) {
476 476
 			$debug_key = Config::get(static::CONF_KEY_DEBUG_DEBUG_KEY, self::KEY_DEBUG);
477
-			$response[ $debug_key ] = $debug_data;
477
+			$response[$debug_key] = $debug_data;
478 478
 		}
479 479
 
480 480
 		return $response;
Please login to merge, or discard this patch.