@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function boot() |
45 | 45 | { |
46 | - if ($this->app instanceof Laravel && $this->app->runningInConsole()) { |
|
46 | + if ( $this->app instanceof Laravel && $this->app->runningInConsole() ) { |
|
47 | 47 | $this->bootLaravelApplication(); |
48 | 48 | |
49 | - } elseif ($this->app instanceof Lumen) { |
|
49 | + } elseif ( $this->app instanceof Lumen ) { |
|
50 | 50 | $this->bootLumenApplication(); |
51 | 51 | } |
52 | 52 | |
53 | - $this->mergeConfigFrom(__DIR__ . '/../resources/config/responder.php', 'responder'); |
|
53 | + $this->mergeConfigFrom( __DIR__ . '/../resources/config/responder.php', 'responder' ); |
|
54 | 54 | |
55 | - $this->commands([ |
|
55 | + $this->commands( [ |
|
56 | 56 | MakeTransformer::class |
57 | - ]); |
|
57 | + ] ); |
|
58 | 58 | |
59 | 59 | include __DIR__ . '/helpers.php'; |
60 | 60 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | $this->registerFractal(); |
70 | 70 | $this->registerResponseBuilders(); |
71 | 71 | |
72 | - $this->app->bind(Responder::class, function ($app) { |
|
73 | - return new Responder($app[SuccessResponseBuilder::class], $app[ErrorResponseBuilder::class]); |
|
72 | + $this->app->bind( Responder::class, function ( $app ) { |
|
73 | + return new Responder( $app[ SuccessResponseBuilder::class ], $app[ ErrorResponseBuilder::class ] ); |
|
74 | 74 | }); |
75 | 75 | |
76 | 76 | $this->registerAliases(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function provides() |
85 | 85 | { |
86 | - return ['responder', 'responder.success', 'responder.error', 'responder.manager', 'responder.serializer']; |
|
86 | + return [ 'responder', 'responder.success', 'responder.error', 'responder.manager', 'responder.serializer' ]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function registerFractal() |
96 | 96 | { |
97 | - $this->app->bind(SerializerAbstract::class, function ($app) { |
|
98 | - $serializer = $app->config->get('responder.serializer'); |
|
97 | + $this->app->bind( SerializerAbstract::class, function ( $app ) { |
|
98 | + $serializer = $app->config->get( 'responder.serializer' ); |
|
99 | 99 | |
100 | 100 | return new $serializer; |
101 | 101 | }); |
102 | 102 | |
103 | - $this->app->bind(Manager::class, function ($app) { |
|
104 | - return (new Manager())->setSerializer($app[SerializerAbstract::class]); |
|
103 | + $this->app->bind( Manager::class, function ( $app ) { |
|
104 | + return (new Manager())->setSerializer( $app[ SerializerAbstract::class ] ); |
|
105 | 105 | }); |
106 | 106 | |
107 | - $this->app->bind(ResourceFactory::class, function () { |
|
107 | + $this->app->bind( ResourceFactory::class, function () { |
|
108 | 108 | return new ResourceFactory(); |
109 | 109 | }); |
110 | 110 | } |
@@ -116,22 +116,22 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function registerResponseBuilders() |
118 | 118 | { |
119 | - $this->app->bind(SuccessResponseBuilder::class, function ($app) { |
|
120 | - $builder = new SuccessResponseBuilder(response(), $app[ResourceFactory::class], $app[Manager::class]); |
|
119 | + $this->app->bind( SuccessResponseBuilder::class, function ( $app ) { |
|
120 | + $builder = new SuccessResponseBuilder( response(), $app[ ResourceFactory::class ], $app[ Manager::class ] ); |
|
121 | 121 | |
122 | - if ($parameter = $app->config->get('responder.load_relations_from_parameter')) { |
|
123 | - $builder->include($this->app[Request::class]->input($parameter, [])); |
|
122 | + if ( $parameter = $app->config->get( 'responder.load_relations_from_parameter' ) ) { |
|
123 | + $builder->include( $this->app[ Request::class ]->input( $parameter, [ ] ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | - $builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag')); |
|
127 | - return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code')); |
|
126 | + $builder->setIncludeSuccessFlag( $app->config->get( 'responder.include_success_flag' ) ); |
|
127 | + return $builder->setIncludeStatusCode( $app->config->get( 'responder.include_status_code' ) ); |
|
128 | 128 | }); |
129 | 129 | |
130 | - $this->app->bind(ErrorResponseBuilder::class, function ($app) { |
|
131 | - $builder = new ErrorResponseBuilder(response(), $app['translator']); |
|
130 | + $this->app->bind( ErrorResponseBuilder::class, function ( $app ) { |
|
131 | + $builder = new ErrorResponseBuilder( response(), $app[ 'translator' ] ); |
|
132 | 132 | |
133 | - $builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag')); |
|
134 | - return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code')); |
|
133 | + $builder->setIncludeSuccessFlag( $app->config->get( 'responder.include_success_flag' ) ); |
|
134 | + return $builder->setIncludeStatusCode( $app->config->get( 'responder.include_status_code' ) ); |
|
135 | 135 | }); |
136 | 136 | } |
137 | 137 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function registerAliases() |
144 | 144 | { |
145 | - $this->app->alias(Responder::class, 'responder'); |
|
146 | - $this->app->alias(SuccessResponseBuilder::class, 'responder.success'); |
|
147 | - $this->app->alias(ErrorResponseBuilder::class, 'responder.error'); |
|
148 | - $this->app->alias(Manager::class, 'responder.manager'); |
|
149 | - $this->app->alias(Manager::class, 'responder.serializer'); |
|
145 | + $this->app->alias( Responder::class, 'responder' ); |
|
146 | + $this->app->alias( SuccessResponseBuilder::class, 'responder.success' ); |
|
147 | + $this->app->alias( ErrorResponseBuilder::class, 'responder.error' ); |
|
148 | + $this->app->alias( Manager::class, 'responder.manager' ); |
|
149 | + $this->app->alias( Manager::class, 'responder.serializer' ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function bootLaravelApplication() |
158 | 158 | { |
159 | - $this->publishes([ |
|
160 | - __DIR__ . '/../resources/config/responder.php' => config_path('responder.php') |
|
161 | - ], 'config'); |
|
159 | + $this->publishes( [ |
|
160 | + __DIR__ . '/../resources/config/responder.php' => config_path( 'responder.php' ) |
|
161 | + ], 'config' ); |
|
162 | 162 | |
163 | - $this->publishes([ |
|
164 | - __DIR__ . '/../resources/lang/en/errors.php' => base_path('resources/lang/en/errors.php') |
|
165 | - ], 'lang'); |
|
163 | + $this->publishes( [ |
|
164 | + __DIR__ . '/../resources/lang/en/errors.php' => base_path( 'resources/lang/en/errors.php' ) |
|
165 | + ], 'lang' ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,6 +172,6 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function bootLumenApplication() |
174 | 174 | { |
175 | - $this->app->configure('responder'); |
|
175 | + $this->app->configure( 'responder' ); |
|
176 | 176 | } |
177 | 177 | } |