@@ -21,5 +21,5 @@ |
||
| 21 | 21 | * @param string|null $resourceKey |
| 22 | 22 | * @return \League\Fractal\Resource\ResourceInterface |
| 23 | 23 | */ |
| 24 | - public function make($data = null, $transformer = null, string $resourceKey = null): ResourceInterface; |
|
| 24 | + public function make( $data = null, $transformer = null, string $resourceKey = null ): ResourceInterface; |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param string|callback $transformer |
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | - public function bind($transformable, $transformer); |
|
| 21 | + public function bind( $transformable, $transformer ); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Resolve a transformer. |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return \Flugg\Responder\Transformers\Transformer|callable |
| 28 | 28 | * @throws \Flugg\Responder\Exceptions\InvalidTransformerException |
| 29 | 29 | */ |
| 30 | - public function resolve($transformer); |
|
| 30 | + public function resolve( $transformer ); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Resolve a transformer from the given data. |
@@ -35,5 +35,5 @@ discard block |
||
| 35 | 35 | * @param mixed $data |
| 36 | 36 | * @return \Flugg\Responder\Transformers\Transformer|callable|null |
| 37 | 37 | */ |
| 38 | - public function resolveFromData($data); |
|
| 38 | + public function resolveFromData( $data ); |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | protected function getStub() |
| 44 | 44 | { |
| 45 | - if ($this->option('model')) { |
|
| 45 | + if ( $this->option( 'model' ) ) { |
|
| 46 | 46 | return __DIR__ . '../../resources/stubs/transformer.model.stub'; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param string $rootNamespace |
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | - protected function getDefaultNamespace($rootNamespace) |
|
| 58 | + protected function getDefaultNamespace( $rootNamespace ) |
|
| 59 | 59 | { |
| 60 | 60 | return $rootNamespace . '\Transformers'; |
| 61 | 61 | } |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | * @param string $name |
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | - protected function buildClass($name) |
|
| 69 | + protected function buildClass( $name ) |
|
| 70 | 70 | { |
| 71 | - $replace = []; |
|
| 71 | + $replace = [ ]; |
|
| 72 | 72 | |
| 73 | - if ($this->option('model')) { |
|
| 74 | - $replace = $this->buildModelReplacements($replace); |
|
| 73 | + if ( $this->option( 'model' ) ) { |
|
| 74 | + $replace = $this->buildModelReplacements( $replace ); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return str_replace(array_keys($replace), array_values($replace), parent::buildClass($name)); |
|
| 77 | + return str_replace( array_keys( $replace ), array_values( $replace ), parent::buildClass( $name ) ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | * @param array $replace |
| 84 | 84 | * @return array |
| 85 | 85 | */ |
| 86 | - protected function buildModelReplacements(array $replace) |
|
| 86 | + protected function buildModelReplacements( array $replace ) |
|
| 87 | 87 | { |
| 88 | - $model = $this->qualifyClass($this->option('model')); |
|
| 88 | + $model = $this->qualifyClass( $this->option( 'model' ) ); |
|
| 89 | 89 | |
| 90 | - return array_merge($replace, [ |
|
| 90 | + return array_merge( $replace, [ |
|
| 91 | 91 | 'DummyFullModelClass' => $model, |
| 92 | - 'DummyModelClass' => class_basename($model), |
|
| 93 | - 'DummyModelVariable' => lcfirst(class_basename($model)), |
|
| 94 | - ]); |
|
| 92 | + 'DummyModelClass' => class_basename( $model ), |
|
| 93 | + 'DummyModelVariable' => lcfirst( class_basename( $model ) ), |
|
| 94 | + ] ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | protected function getOptions() |
| 103 | 103 | { |
| 104 | 104 | return [ |
| 105 | - ['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a model transformerl.'], |
|
| 105 | + [ 'model', 'm', InputOption::VALUE_OPTIONAL, 'Generate a model transformerl.' ], |
|
| 106 | 106 | ]; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | \ No newline at end of file |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | * @param string|null $message |
| 23 | 23 | * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder |
| 24 | 24 | */ |
| 25 | - public function error(string $errorCode = null, string $message = null): ErrorResponseBuilder |
|
| 25 | + public function error( string $errorCode = null, string $message = null ): ErrorResponseBuilder |
|
| 26 | 26 | { |
| 27 | - return app(Responder::class)->error(...func_get_args()); |
|
| 27 | + return app( Responder::class )->error( ...func_get_args() ); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * @param string|null $resourceKey |
| 36 | 36 | * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder |
| 37 | 37 | */ |
| 38 | - public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder |
|
| 38 | + public function success( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder |
|
| 39 | 39 | { |
| 40 | - return app(Responder::class)->success(...func_get_args()); |
|
| 40 | + return app( Responder::class )->success( ...func_get_args() ); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory |
| 38 | 38 | */ |
| 39 | - public function __construct(ResponseFactory $responseFactory) |
|
| 39 | + public function __construct( ResponseFactory $responseFactory ) |
|
| 40 | 40 | { |
| 41 | 41 | $this->responseFactory = $responseFactory; |
| 42 | 42 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * @param array $headers |
| 49 | 49 | * @return \Illuminate\Http\JsonResponse |
| 50 | 50 | */ |
| 51 | - public function respond(int $status = null, array $headers = []): JsonResponse |
|
| 51 | + public function respond( int $status = null, array $headers = [ ] ): JsonResponse |
|
| 52 | 52 | { |
| 53 | - if (! is_null($status)) { |
|
| 54 | - $this->setStatusCode($status); |
|
| 53 | + if ( ! is_null( $status ) ) { |
|
| 54 | + $this->setStatusCode( $status ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return $this->responseFactory->make($this->toArray(), $this->status, $headers); |
|
| 57 | + return $this->responseFactory->make( $this->toArray(), $this->status, $headers ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function toCollection(): Collection |
| 76 | 76 | { |
| 77 | - return new Collection($this->toArray()); |
|
| 77 | + return new Collection( $this->toArray() ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | * @param int $options |
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | - public function toJson($options = 0): string |
|
| 86 | + public function toJson( $options = 0 ): string |
|
| 87 | 87 | { |
| 88 | - return json_encode($this->toArray(), $options); |
|
| 88 | + return json_encode( $this->toArray(), $options ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param int $status |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - protected function setStatusCode(int $status): void |
|
| 97 | + protected function setStatusCode( int $status ): void |
|
| 98 | 98 | { |
| 99 | - $this->validateStatusCode($this->status = $status); |
|
| 99 | + $this->validateStatusCode( $this->status = $status ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -112,5 +112,5 @@ discard block |
||
| 112 | 112 | * @param int $status |
| 113 | 113 | * @return void |
| 114 | 114 | */ |
| 115 | - abstract protected function validateStatusCode(int $status): void; |
|
| 115 | + abstract protected function validateStatusCode( int $status ): void; |
|
| 116 | 116 | } |
| 117 | 117 | \ No newline at end of file |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | * @param \Flugg\Responder\Contracts\ResponseFactory $responseFactory |
| 47 | 47 | * @param \Flugg\Responder\TransformBuilder $transformBuilder |
| 48 | 48 | */ |
| 49 | - public function __construct(ResponseFactory $responseFactory, TransformBuilder $transformBuilder) |
|
| 49 | + public function __construct( ResponseFactory $responseFactory, TransformBuilder $transformBuilder ) |
|
| 50 | 50 | { |
| 51 | 51 | $this->transformBuilder = $transformBuilder; |
| 52 | 52 | |
| 53 | - parent::__construct($responseFactory); |
|
| 53 | + parent::__construct( $responseFactory ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @param string|null $resourceKey |
| 62 | 62 | * @return self |
| 63 | 63 | */ |
| 64 | - public function transform($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder |
|
| 64 | + public function transform( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder |
|
| 65 | 65 | { |
| 66 | - $this->transformBuilder->resource($data, $transformer, $resourceKey); |
|
| 66 | + $this->transformBuilder->resource( $data, $transformer, $resourceKey ); |
|
| 67 | 67 | |
| 68 | 68 | return $this; |
| 69 | 69 | } |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | * @param array $arguments |
| 76 | 76 | * @return self|void |
| 77 | 77 | */ |
| 78 | - public function __call($name, $arguments) |
|
| 78 | + public function __call( $name, $arguments ) |
|
| 79 | 79 | { |
| 80 | - if (in_array($name, ['meta', 'with', 'without', 'serializer', 'paginator', 'cursor'])) { |
|
| 81 | - $this->transformBuilder->$name(...$arguments); |
|
| 80 | + if ( in_array( $name, [ 'meta', 'with', 'without', 'serializer', 'paginator', 'cursor' ] ) ) { |
|
| 81 | + $this->transformBuilder->$name( ...$arguments ); |
|
| 82 | 82 | |
| 83 | 83 | return $this; |
| 84 | 84 | } |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | * @return void |
| 104 | 104 | * @throws \InvalidArgumentException |
| 105 | 105 | */ |
| 106 | - protected function validateStatusCode(int $status): void |
|
| 106 | + protected function validateStatusCode( int $status ): void |
|
| 107 | 107 | { |
| 108 | - if ($status < 100 || $status >= 400) { |
|
| 109 | - throw new InvalidArgumentException("{$status} is not a valid success HTTP status code."); |
|
| 108 | + if ( $status < 100 || $status >= 400 ) { |
|
| 109 | + throw new InvalidArgumentException( "{$status} is not a valid success HTTP status code." ); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param \Illuminate\Contracts\Routing\ResponseFactory $factory |
| 29 | 29 | */ |
| 30 | - public function __construct(BaseLaravelResponseFactory $factory) |
|
| 30 | + public function __construct( BaseLaravelResponseFactory $factory ) |
|
| 31 | 31 | { |
| 32 | 32 | $this->factory = $factory; |
| 33 | 33 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * @param array $headers |
| 41 | 41 | * @return \Illuminate\Http\JsonResponse |
| 42 | 42 | */ |
| 43 | - public function make(array $data, int $status, array $headers = []): JsonResponse |
|
| 43 | + public function make( array $data, int $status, array $headers = [ ] ): JsonResponse |
|
| 44 | 44 | { |
| 45 | - return $this->factory->json($data, $status, $headers); |
|
| 45 | + return $this->factory->json( $data, $status, $headers ); |
|
| 46 | 46 | } |
| 47 | 47 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param \Laravel\Lumen\Http\ResponseFactory $factory |
| 29 | 29 | */ |
| 30 | - public function __construct(BaseLumenResponseFactory $factory) |
|
| 30 | + public function __construct( BaseLumenResponseFactory $factory ) |
|
| 31 | 31 | { |
| 32 | 32 | $this->factory = $factory; |
| 33 | 33 | } |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * @param array $headers |
| 41 | 41 | * @return \Illuminate\Http\JsonResponse |
| 42 | 42 | */ |
| 43 | - public function make(array $data, int $status, array $headers = []): JsonResponse |
|
| 43 | + public function make( array $data, int $status, array $headers = [ ] ): JsonResponse |
|
| 44 | 44 | { |
| 45 | - return $this->factory->json($data, $status, $headers); |
|
| 45 | + return $this->factory->json( $data, $status, $headers ); |
|
| 46 | 46 | } |
| 47 | 47 | } |
@@ -21,10 +21,10 @@ |
||
| 21 | 21 | * @param array $headers |
| 22 | 22 | * @return \Illuminate\Http\JsonResponse |
| 23 | 23 | */ |
| 24 | - public function make(array $data, int $status, array $headers = []): JsonResponse |
|
| 24 | + public function make( array $data, int $status, array $headers = [ ] ): JsonResponse |
|
| 25 | 25 | { |
| 26 | - return $this->factory->make(array_merge([ |
|
| 26 | + return $this->factory->make( array_merge( [ |
|
| 27 | 27 | 'success' => $status >= 100 || $status < 400, |
| 28 | - ], $data), $status, $headers); |
|
| 28 | + ], $data ), $status, $headers ); |
|
| 29 | 29 | } |
| 30 | 30 | } |