Completed
Push — dev ( 7cd82e...52b41a )
by Marcin
03:42
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/Converter.php 1 patch
Spacing   +7 added lines, -7 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 ($cls instanceof $class_name) {
64
-					$result = $this->classes[ $cls ];
64
+					$result = $this->classes[$cls];
65 65
 					break;
66 66
 				}
67 67
 			}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 		if (is_object($data)) {
81 81
 			$cfg = $this->getClassMappingConfigOrThrow($data);
82
-			$data = [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()];
82
+			$data = [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()];
83 83
 		} else {
84 84
 			if (!is_array($data) && $data !== null) {
85 85
 				throw new \InvalidArgumentException(
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		if (is_object($data)) {
113 113
 			$cfg = $this->getClassMappingConfigOrThrow($data);
114 114
 
115
-			return [$cfg[ ResponseBuilder::KEY_KEY ] => $data->{$cfg[ ResponseBuilder::KEY_METHOD ]}()];
115
+			return [$cfg[ResponseBuilder::KEY_KEY] => $data->{$cfg[ResponseBuilder::KEY_METHOD]}()];
116 116
 		}
117 117
 
118 118
 		// This is to ensure that we either have array with user provided keys i.e. ['foo'=>'bar'], which will then
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 //							sprintf('Invalid payload data. Must be null, array or object ("%s" given).', gettype($data)));
145 145
 //					}
146 146
 				}
147
-				$data[ $key ] = $this->convertArray($val);
147
+				$data[$key] = $this->convertArray($val);
148 148
 			} elseif (is_object($val)) {
149 149
 				$cls = get_class($val);
150 150
 				$cfg = $this->getClassMappingConfigOrThrow($val);
151 151
 				if (array_key_exists($cls, $this->classes)) {
152
-					$conversion_method = $this->classes[ $cls ][ ResponseBuilder::KEY_METHOD ];
152
+					$conversion_method = $this->classes[$cls][ResponseBuilder::KEY_METHOD];
153 153
 					$converted_data = $val->$conversion_method();
154 154
 //							$data = [$this->classes[ $cls ][ ResponseBuilder::KEY_KEY ] => $converted_data];
155
-					$data[ $key ] = $converted_data;
155
+					$data[$key] = $converted_data;
156 156
 				}
157 157
 			}
158 158
 		}
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
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 		if ($data !== null && !is_object($data)) {
471 471
 			// ensure we get object in final JSON structure in data node
472
-			$data = (object)$data;
472
+			$data = (object) $data;
473 473
 		}
474 474
 
475 475
 		/** @noinspection PhpUndefinedClassInspection */
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
 		if ($debug_data !== null) {
485 485
 			$debug_key = Config::get(static::CONF_KEY_DEBUG_DEBUG_KEY, self::KEY_DEBUG);
486
-			$response[ $debug_key ] = $debug_data;
486
+			$response[$debug_key] = $debug_data;
487 487
 		}
488 488
 
489 489
 		return $response;
Please login to merge, or discard this patch.