@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function register() |
| 50 | 50 | { |
| 51 | - if ($this->app instanceof Laravel) { |
|
| 51 | + if ( $this->app instanceof Laravel ) { |
|
| 52 | 52 | $this->registerLaravelBindings(); |
| 53 | - } elseif ($this->app instanceof Lumen) { |
|
| 53 | + } elseif ( $this->app instanceof Lumen ) { |
|
| 54 | 54 | $this->registerLumenBindings(); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | protected function registerLaravelBindings() |
| 72 | 72 | { |
| 73 | - $this->app->bind(ResponseFactoryContract::class, function ($app) { |
|
| 74 | - return $this->decorateResponseFactory($app->make(LaravelResponseFactory::class)); |
|
| 73 | + $this->app->bind( ResponseFactoryContract::class, function ( $app ) { |
|
| 74 | + return $this->decorateResponseFactory( $app->make( LaravelResponseFactory::class ) ); |
|
| 75 | 75 | }); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected function registerLumenBindings() |
| 84 | 84 | { |
| 85 | - $this->app->bind(ResponseFactoryContract::class, function ($app) { |
|
| 86 | - return $this->decorateResponseFactory($app->make(LumenResponseFactory::class)); |
|
| 85 | + $this->app->bind( ResponseFactoryContract::class, function ( $app ) { |
|
| 86 | + return $this->decorateResponseFactory( $app->make( LumenResponseFactory::class ) ); |
|
| 87 | 87 | }); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | * @param \Flugg\Responder\Contracts\ResponseFactory $factory |
| 94 | 94 | * @return void |
| 95 | 95 | */ |
| 96 | - protected function decorateResponseFactory(ResponseFactoryContract $factory) |
|
| 96 | + protected function decorateResponseFactory( ResponseFactoryContract $factory ) |
|
| 97 | 97 | { |
| 98 | - foreach ($this->app->config['responder.decorators'] as $decorator) { |
|
| 99 | - $factory = new $decorator($factory); |
|
| 98 | + foreach ( $this->app->config[ 'responder.decorators' ] as $decorator ) { |
|
| 99 | + $factory = new $decorator( $factory ); |
|
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | 102 | return $factory; |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected function registerSerializerBindings() |
| 111 | 111 | { |
| 112 | - $this->app->bind(ErrorSerializerContract::class, function ($app) { |
|
| 113 | - return $app->make($app->config['responder.serializers.error']); |
|
| 112 | + $this->app->bind( ErrorSerializerContract::class, function ( $app ) { |
|
| 113 | + return $app->make( $app->config[ 'responder.serializers.error' ] ); |
|
| 114 | 114 | }); |
| 115 | 115 | |
| 116 | - $this->app->bind(SerializerAbstract::class, function ($app) { |
|
| 117 | - return $app->make($app->config['responder.serializers.success']); |
|
| 116 | + $this->app->bind( SerializerAbstract::class, function ( $app ) { |
|
| 117 | + return $app->make( $app->config[ 'responder.serializers.success' ] ); |
|
| 118 | 118 | }); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -125,12 +125,12 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function registerErrorBindings() |
| 127 | 127 | { |
| 128 | - $this->app->bind(ErrorMessageResolverContract::class, function () { |
|
| 129 | - return $app->make(ErrorMessageResolver::class); |
|
| 128 | + $this->app->bind( ErrorMessageResolverContract::class, function () { |
|
| 129 | + return $app->make( ErrorMessageResolver::class ); |
|
| 130 | 130 | }); |
| 131 | 131 | |
| 132 | - $this->app->bind(ErrorFactoryContract::class, function ($app) { |
|
| 133 | - return $app->make(ErrorFactory::class); |
|
| 132 | + $this->app->bind( ErrorFactoryContract::class, function ( $app ) { |
|
| 133 | + return $app->make( ErrorFactory::class ); |
|
| 134 | 134 | }); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | protected function registerFractalBindings() |
| 143 | 143 | { |
| 144 | - $this->app->bind(Manager::class, function ($app) { |
|
| 145 | - return $app->make(Manager::class)->setRecursionLimit($app->config['responder.recursion_limit']); |
|
| 144 | + $this->app->bind( Manager::class, function ( $app ) { |
|
| 145 | + return $app->make( Manager::class )->setRecursionLimit( $app->config[ 'responder.recursion_limit' ] ); |
|
| 146 | 146 | }); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function registerResourceBindings() |
| 155 | 155 | { |
| 156 | - $this->app->bind(ResourceFactoryContract::class, function ($app) { |
|
| 157 | - return $app->make(ResourceFactory::class); |
|
| 156 | + $this->app->bind( ResourceFactoryContract::class, function ( $app ) { |
|
| 157 | + return $app->make( ResourceFactory::class ); |
|
| 158 | 158 | }); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function registerPaginationBindings() |
| 167 | 167 | { |
| 168 | - $this->app->bind(PaginatorFactoryContract::class, function ($app) { |
|
| 169 | - return new PaginatorFactory($app->make(Request::class)->query()); |
|
| 168 | + $this->app->bind( PaginatorFactoryContract::class, function ( $app ) { |
|
| 169 | + return new PaginatorFactory( $app->make( Request::class )->query() ); |
|
| 170 | 170 | }); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -177,19 +177,19 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function registerTransformationBindings() |
| 179 | 179 | { |
| 180 | - $this->app->bind(TransformFactoryContract::class, function () { |
|
| 181 | - return $app->make(FractalTransformFactory::class); |
|
| 180 | + $this->app->bind( TransformFactoryContract::class, function () { |
|
| 181 | + return $app->make( FractalTransformFactory::class ); |
|
| 182 | 182 | }); |
| 183 | 183 | |
| 184 | - $this->app->bind(TransformBuilder::class, function ($app) { |
|
| 185 | - return $app->make(TransformBuilder::class) |
|
| 186 | - ->serializer($app->make(SerializerAbstract::class)) |
|
| 187 | - ->with($app->make(Request::class)->input($app->config['responder.load_relations_parameter'], [])) |
|
| 188 | - ->only($app->make(Request::class)->input($app->config['responder.filter_fields_parameter'], [])); |
|
| 184 | + $this->app->bind( TransformBuilder::class, function ( $app ) { |
|
| 185 | + return $app->make( TransformBuilder::class ) |
|
| 186 | + ->serializer( $app->make( SerializerAbstract::class ) ) |
|
| 187 | + ->with( $app->make( Request::class )->input( $app->config[ 'responder.load_relations_parameter' ], [ ] ) ) |
|
| 188 | + ->only( $app->make( Request::class )->input( $app->config[ 'responder.filter_fields_parameter' ], [ ] ) ); |
|
| 189 | 189 | }); |
| 190 | 190 | |
| 191 | - $this->app->bind(TransformerResolverContract::class, function ($app) { |
|
| 192 | - return $app->make(TransformerResolver::class); |
|
| 191 | + $this->app->bind( TransformerResolverContract::class, function ( $app ) { |
|
| 192 | + return $app->make( TransformerResolver::class ); |
|
| 193 | 193 | }); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -200,12 +200,12 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | protected function registerServiceBindings() |
| 202 | 202 | { |
| 203 | - $this->app->bind(ResponderContract::class, function ($app) { |
|
| 204 | - return $app->make(Responder::class); |
|
| 203 | + $this->app->bind( ResponderContract::class, function ( $app ) { |
|
| 204 | + return $app->make( Responder::class ); |
|
| 205 | 205 | }); |
| 206 | 206 | |
| 207 | - $this->app->bind(TransformerContract::class, function ($app) { |
|
| 208 | - return $app->make(Transformer::class); |
|
| 207 | + $this->app->bind( TransformerContract::class, function ( $app ) { |
|
| 208 | + return $app->make( Transformer::class ); |
|
| 209 | 209 | }); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function boot() |
| 218 | 218 | { |
| 219 | - if ($this->app instanceof Laravel) { |
|
| 219 | + if ( $this->app instanceof Laravel ) { |
|
| 220 | 220 | $this->bootLaravelApplication(); |
| 221 | - } elseif ($this->app instanceof Lumen) { |
|
| 221 | + } elseif ( $this->app instanceof Lumen ) { |
|
| 222 | 222 | $this->bootLumenApplication(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $this->mergeConfigFrom(__DIR__ . '/../config/responder.php', 'responder'); |
|
| 226 | - $this->commands(MakeTransformer::class); |
|
| 225 | + $this->mergeConfigFrom( __DIR__ . '/../config/responder.php', 'responder' ); |
|
| 226 | + $this->commands( MakeTransformer::class ); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | protected function bootLaravelApplication() |
| 235 | 235 | { |
| 236 | - if ($this->app->runningInConsole()) { |
|
| 237 | - $this->publishes([ |
|
| 238 | - __DIR__ . '/../resources/config/responder.php' => config_path('responder.php'), |
|
| 239 | - ], 'config'); |
|
| 236 | + if ( $this->app->runningInConsole() ) { |
|
| 237 | + $this->publishes( [ |
|
| 238 | + __DIR__ . '/../resources/config/responder.php' => config_path( 'responder.php' ), |
|
| 239 | + ], 'config' ); |
|
| 240 | 240 | |
| 241 | - $this->publishes([ |
|
| 242 | - __DIR__ . '/../resources/lang/en/errors.php' => base_path('resources/lang/en/errors.php'), |
|
| 243 | - ], 'lang'); |
|
| 241 | + $this->publishes( [ |
|
| 242 | + __DIR__ . '/../resources/lang/en/errors.php' => base_path( 'resources/lang/en/errors.php' ), |
|
| 243 | + ], 'lang' ); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -251,6 +251,6 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | protected function bootLumenApplication() |
| 253 | 253 | { |
| 254 | - $this->app->configure('responder'); |
|
| 254 | + $this->app->configure( 'responder' ); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | \ 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 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param \Flugg\Responder\Contracts\ResponseFactory $factory |
| 28 | 28 | */ |
| 29 | - public function __construct(ResponseFactory $factory) |
|
| 29 | + public function __construct( ResponseFactory $factory ) |
|
| 30 | 30 | { |
| 31 | 31 | $this->factory = $factory; |
| 32 | 32 | } |
@@ -39,5 +39,5 @@ discard block |
||
| 39 | 39 | * @param array $headers |
| 40 | 40 | * @return \Illuminate\Http\JsonResponse |
| 41 | 41 | */ |
| 42 | - abstract public function make(array $data, int $status, array $headers = []): JsonResponse; |
|
| 42 | + abstract public function make( array $data, int $status, array $headers = [ ] ): JsonResponse; |
|
| 43 | 43 | } |
@@ -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 | 'status' => $status, |
| 28 | - ], $data), $status, $headers); |
|
| 28 | + ], $data ), $status, $headers ); |
|
| 29 | 29 | } |
| 30 | 30 | } |