@@ -33,7 +33,7 @@ |
||
33 | 33 | */ |
34 | 34 | protected function getRelationshipKeys(ResourceInterface $resource): array |
35 | 35 | { |
36 | - $keys = []; |
|
36 | + $keys = [ ]; |
|
37 | 37 | foreach ($resource->getRelationships() as $key => $relationships) { |
38 | 38 | if (!empty($relationships)) { |
39 | 39 | array_push($keys, ...$relationships); |
@@ -55,7 +55,7 @@ |
||
55 | 55 | (new \ReflectionClass($model))->getShortName()); |
56 | 56 | $transformer = resolve($transformerClass); |
57 | 57 | } catch (\Exception $e) { |
58 | - throw new UnresolvedTransformerException('Unable to resolve transformer for model: '.\get_class($model), |
|
58 | + throw new UnresolvedTransformerException('Unable to resolve transformer for model: ' . \get_class($model), |
|
59 | 59 | 0, $e); |
60 | 60 | } |
61 | 61 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param \Rexlabs\Smokescreen\Smokescreen $smokescreen |
78 | 78 | * @param array $config |
79 | 79 | */ |
80 | - public function __construct(\Rexlabs\Smokescreen\Smokescreen $smokescreen, array $config = []) |
|
80 | + public function __construct(\Rexlabs\Smokescreen\Smokescreen $smokescreen, array $config = [ ]) |
|
81 | 81 | { |
82 | 82 | $this->smokescreen = $smokescreen; |
83 | 83 | $this->setConfig($config); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return static |
93 | 93 | */ |
94 | - public static function make(\Rexlabs\Smokescreen\Smokescreen $smokescreen = null, array $config = []) |
|
94 | + public static function make(\Rexlabs\Smokescreen\Smokescreen $smokescreen = null, array $config = [ ]) |
|
95 | 95 | { |
96 | 96 | return new static($smokescreen ?? new \Rexlabs\Smokescreen\Smokescreen(), $config); |
97 | 97 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } elseif ($data instanceof Builder) { |
229 | 229 | $data = $data->get(); |
230 | 230 | } elseif ($data instanceof Model) { |
231 | - $data = new Collection([$data]); |
|
231 | + $data = new Collection([ $data ]); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | // Create a new collection resource |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function inject($key, $data) |
367 | 367 | { |
368 | - $this->injections[$key] = $data; |
|
368 | + $this->injections[ $key ] = $data; |
|
369 | 369 | |
370 | 370 | return $this; |
371 | 371 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | // underlying model and attempt to resolve a transformer class. |
416 | 416 | if ($this->smokescreen->getTransformerResolver() === null) { |
417 | 417 | $this->smokescreen->setTransformerResolver( |
418 | - new TransformerResolver($this->config['transformer_namespace'] ?? 'App\\Transformers') |
|
418 | + new TransformerResolver($this->config[ 'transformer_namespace' ] ?? 'App\\Transformers') |
|
419 | 419 | ); |
420 | 420 | } |
421 | 421 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | return $this->autoParseIncludes; |
468 | 468 | } |
469 | 469 | |
470 | - return $this->config['include_key'] ?? 'include'; |
|
470 | + return $this->config[ 'include_key' ] ?? 'include'; |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * |
508 | 508 | * @see Smokescreen::toArray() |
509 | 509 | */ |
510 | - public function response(int $statusCode = 200, array $headers = [], int $options = 0): JsonResponse |
|
510 | + public function response(int $statusCode = 200, array $headers = [ ], int $options = 0): JsonResponse |
|
511 | 511 | { |
512 | 512 | // Response will only be generated once. use clearResponse() to clear. |
513 | 513 | if ($this->response === null) { |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * @see Smokescreen::toArray() |
536 | 536 | * @see Smokescreen::response() |
537 | 537 | */ |
538 | - public function freshResponse(int $statusCode = 200, array $headers = [], int $options = 0): JsonResponse |
|
538 | + public function freshResponse(int $statusCode = 200, array $headers = [ ], int $options = 0): JsonResponse |
|
539 | 539 | { |
540 | 540 | $this->clearResponse(); |
541 | 541 | |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | */ |
653 | 653 | protected function setConfig(array $config) |
654 | 654 | { |
655 | - if (!empty($config['default_serializer'])) { |
|
656 | - $serializer = $config['default_serializer']; |
|
655 | + if (!empty($config[ 'default_serializer' ])) { |
|
656 | + $serializer = $config[ 'default_serializer' ]; |
|
657 | 657 | if (\is_string($serializer)) { |
658 | 658 | // Given serializer is expected to be a class path |
659 | 659 | // Instantiate via the container |
660 | 660 | $serializer = app()->make($serializer); |
661 | 661 | } |
662 | 662 | $this->serializeWith($serializer); |
663 | - unset($config['default_serializer']); |
|
663 | + unset($config[ 'default_serializer' ]); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | $this->config = $config; |
@@ -37,13 +37,13 @@ |
||
37 | 37 | */ |
38 | 38 | public function listForEloquent(string $class) : array |
39 | 39 | { |
40 | - $list = []; |
|
40 | + $list = [ ]; |
|
41 | 41 | $table = (new $class)->getTable(); |
42 | 42 | $columns = Schema::getColumnListing($table); |
43 | 43 | |
44 | 44 | foreach ($columns as $column) { |
45 | 45 | $type = Schema::getColumnType($table, $column); |
46 | - $list[$column] = $this->typesMap[$type] ?? null; |
|
46 | + $list[ $column ] = $this->typesMap[ $type ] ?? null; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $list; |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function listForEloquent(string $class) : array |
39 | 39 | { |
40 | - $list = []; |
|
40 | + $list = [ ]; |
|
41 | 41 | $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC); |
42 | - $declaredMethods = array_filter($methods, function ($method) use ($class) { |
|
42 | + $declaredMethods = array_filter($methods, function($method) use ($class) { |
|
43 | 43 | return $method->getDeclaringClass()->getName() == $class; |
44 | 44 | }); |
45 | 45 | |
46 | 46 | foreach ($declaredMethods as $method) { |
47 | 47 | if ($type = $this->getResourceTypeByMethodReturnType($method)) { |
48 | - $list[$method->getName()] = "relation|{$type}"; |
|
48 | + $list[ $method->getName() ] = "relation|{$type}"; |
|
49 | 49 | } elseif ($type = $this->getResourceTypeByMethodDefinition($method)) { |
50 | - $list[$method->getName()] = "relation|{$type}"; |
|
50 | + $list[ $method->getName() ] = "relation|{$type}"; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $relation = lcfirst(class_basename($returnType)); |
77 | 77 | |
78 | - return $this->relationsMap[$relation] ?? null; |
|
78 | + return $this->relationsMap[ $relation ] ?? null; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -35,8 +35,8 @@ |
||
35 | 35 | */ |
36 | 36 | public function register() |
37 | 37 | { |
38 | - $this->app->singleton(Smokescreen::class, function () { |
|
39 | - return new Smokescreen(new \Rexlabs\Smokescreen\Smokescreen(), config('smokescreen', [])); |
|
38 | + $this->app->singleton(Smokescreen::class, function() { |
|
39 | + return new Smokescreen(new \Rexlabs\Smokescreen\Smokescreen(), config('smokescreen', [ ])); |
|
40 | 40 | }); |
41 | 41 | $this->app->alias(Smokescreen::class, 'smokescreen'); |
42 | 42 |