Conditions | 3 |
Paths | 2 |
Total Lines | 82 |
Code Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
149 | private function bindApieServices() |
||
150 | { |
||
151 | /** |
||
152 | * ApiResourcesInterface::class: get all resources of the current Apie instance. |
||
153 | */ |
||
154 | $this->app->bind(ApiResourcesInterface::class, function () { |
||
155 | return new ApiResources($this->app->get(Apie::class)->getResources()); |
||
156 | }); |
||
157 | |||
158 | /** |
||
159 | * Apie::class: current Apie instance. |
||
160 | */ |
||
161 | $this->app->bind(Apie::class, function () { |
||
162 | /** @var ApieContext $context */ |
||
163 | $context = $this->app->get(ApieContext::class)->getActiveContext(); |
||
164 | return $context->getApie(); |
||
165 | }); |
||
166 | |||
167 | /** |
||
168 | * IlluminatePlugin::class: current IlluminatePlugin instance |
||
169 | */ |
||
170 | $this->app->bind(IlluminatePlugin::class, function () { |
||
171 | /** @var Apie $apie */ |
||
172 | $apie = $this->app->get(Apie::class); |
||
173 | return $apie->getPlugin(IlluminatePlugin::class); |
||
174 | }); |
||
175 | |||
176 | /** |
||
177 | * ApplicationInfoRetriever::class: get retriever for Application Info of current apie instance. |
||
178 | */ |
||
179 | $this->app->bind(ApplicationInfoRetriever::class, function () { |
||
180 | /** @var IlluminatePlugin $laravelPlugin */ |
||
181 | $laravelPlugin = $this->app->get(IlluminatePlugin::class); |
||
182 | $config = $laravelPlugin->getLaravelConfig(); |
||
183 | return new ApplicationInfoRetriever( |
||
184 | config('app.name'), |
||
185 | config('app.env'), |
||
186 | $config['metadata']['hash'], |
||
187 | config('app.debug') |
||
188 | ); |
||
189 | }); |
||
190 | |||
191 | /** |
||
192 | * FileStorageDataLayer::class: get file storage data layer for current apie instance. |
||
193 | */ |
||
194 | $this->app->bind(FileStorageDataLayer::class, function () { |
||
195 | return $this->app->get(FileStorageDataLayerContainer::class)->getCurrentFileStorageDataLayer(); |
||
196 | }); |
||
197 | |||
198 | /** |
||
199 | * ApieExceptionToResponse::class: converts exception to an Apie response. |
||
200 | */ |
||
201 | $this->app->bind(ApieExceptionToResponse::class, function () { |
||
202 | /** @var IlluminatePlugin $laravelPlugin */ |
||
203 | $laravelPlugin = $this->app->get(IlluminatePlugin::class); |
||
204 | $config = $laravelPlugin->getLaravelConfig(); |
||
205 | $mapping = $config['exception-mapping']; |
||
206 | return new ApieExceptionToResponse($this->app->make(HttpFoundationFactory::class), $mapping); |
||
207 | }); |
||
208 | |||
209 | /** |
||
210 | * Serializer::class: gets the Symfony serializer. |
||
211 | */ |
||
212 | $this->app->bind(Serializer::class, function () { |
||
213 | $serializer = $this->app->get(ResourceSerializerInterface::class); |
||
214 | if (! ($serializer instanceof SymfonySerializerAdapter)) { |
||
215 | throw new InvalidClassTypeException('resource serializer', SymfonySerializerAdapter::class); |
||
216 | } |
||
217 | return $serializer->getSerializer(); |
||
218 | }); |
||
219 | $this->app->bind(SerializerInterface::class, Serializer::class); |
||
220 | $this->app->bind(NormalizerInterface::class, Serializer::class); |
||
221 | $this->app->bind(DenormalizerInterface::class, Serializer::class); |
||
222 | |||
223 | $todo = [ |
||
224 | [ApiResourceFacade::class, 'getApiResourceFacade'], |
||
225 | [ClassResourceConverter::class, 'getClassResourceConverter'], |
||
226 | [OpenApiSpecGenerator::class, 'getOpenApiSpecGenerator'], |
||
227 | [ResourceSerializerInterface::class, 'getResourceSerializer'] |
||
228 | ]; |
||
229 | while ($item = array_pop($todo)) { |
||
230 | $this->registerApieService($item[0], $item[1]); |
||
231 | } |
||
252 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths