| Conditions | 3 |
| Paths | 2 |
| Total Lines | 100 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 182 | private function bindApieServices() |
||
| 183 | { |
||
| 184 | /** |
||
| 185 | * ApiResourcesInterface::class: get all resources of the current Apie instance. |
||
| 186 | */ |
||
| 187 | $this->app->bind(ApiResourcesInterface::class, function () { |
||
| 188 | return new ApiResources($this->app->get(Apie::class)->getResources()); |
||
| 189 | }); |
||
| 190 | |||
| 191 | /** |
||
| 192 | * ApiResourcePersister: call the correct data layer persist functionality. |
||
| 193 | */ |
||
| 194 | $this->app->bind(ApiResourcePersister::class, function () { |
||
| 195 | return new ApiResourcePersister($this->app->get(Apie::class)->getApiResourceMetadataFactory()); |
||
| 196 | }); |
||
| 197 | |||
| 198 | /** |
||
| 199 | * ApiResourcePersister: call the correct data layer retrieve functionality. |
||
| 200 | */ |
||
| 201 | $this->app->bind(ApiResourceRetriever::class, function () { |
||
| 202 | return new ApiResourceRetriever($this->app->get(Apie::class)->getApiResourceMetadataFactory()); |
||
| 203 | }); |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Apie::class: current Apie instance. |
||
| 207 | */ |
||
| 208 | $this->app->bind(Apie::class, function () { |
||
| 209 | /** @var ApieContext $context */ |
||
| 210 | $context = $this->app->get(ApieContext::class)->getActiveContext(); |
||
| 211 | return $context->getApie(); |
||
| 212 | }); |
||
| 213 | |||
| 214 | /** |
||
| 215 | * IlluminatePlugin::class: current IlluminatePlugin instance |
||
| 216 | */ |
||
| 217 | $this->app->bind(IlluminatePlugin::class, function () { |
||
| 218 | /** @var Apie $apie */ |
||
| 219 | $apie = $this->app->get(Apie::class); |
||
| 220 | return $apie->getPlugin(IlluminatePlugin::class); |
||
| 221 | }); |
||
| 222 | |||
| 223 | /** |
||
| 224 | * ApplicationInfoRetriever::class: get retriever for Application Info of current apie instance. |
||
| 225 | */ |
||
| 226 | $this->app->bind(ApplicationInfoRetriever::class, function () { |
||
| 227 | /** @var IlluminatePlugin $laravelPlugin */ |
||
| 228 | $laravelPlugin = $this->app->get(IlluminatePlugin::class); |
||
| 229 | $config = $laravelPlugin->getLaravelConfig(); |
||
| 230 | return new ApplicationInfoRetriever( |
||
| 231 | config('app.name'), |
||
| 232 | config('app.env'), |
||
| 233 | $config['metadata']['hash'], |
||
| 234 | config('app.debug') |
||
| 235 | ); |
||
| 236 | }); |
||
| 237 | |||
| 238 | /** |
||
| 239 | * FileStorageDataLayer::class: get file storage data layer for current apie instance. |
||
| 240 | */ |
||
| 241 | $this->app->bind(FileStorageDataLayer::class, function () { |
||
| 242 | return $this->app->get(FileStorageDataLayerContainer::class)->getCurrentFileStorageDataLayer(); |
||
| 243 | }); |
||
| 244 | |||
| 245 | $this->app->singleton(TranslationRetriever::class); |
||
| 246 | |||
| 247 | /** |
||
| 248 | * ApieExceptionToResponse::class: converts exception to an Apie response. |
||
| 249 | */ |
||
| 250 | $this->app->bind(ApieExceptionToResponse::class, function () { |
||
| 251 | /** @var IlluminatePlugin $laravelPlugin */ |
||
| 252 | $laravelPlugin = $this->app->get(IlluminatePlugin::class); |
||
| 253 | $config = $laravelPlugin->getLaravelConfig(); |
||
| 254 | $mapping = $config['exception-mapping']; |
||
| 255 | return new ApieExceptionToResponse($this->app->make(HttpFoundationFactory::class), $mapping); |
||
| 256 | }); |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Serializer::class: gets the Symfony serializer. |
||
| 260 | */ |
||
| 261 | $this->app->bind(Serializer::class, function () { |
||
| 262 | $serializer = $this->app->get(ResourceSerializerInterface::class); |
||
| 263 | if (! ($serializer instanceof SymfonySerializerAdapter)) { |
||
| 264 | throw new InvalidClassTypeException('resource serializer', SymfonySerializerAdapter::class); |
||
| 265 | } |
||
| 266 | return $serializer->getSerializer(); |
||
| 267 | }); |
||
| 268 | $this->app->bind(SerializerInterface::class, Serializer::class); |
||
| 269 | $this->app->bind(NormalizerInterface::class, Serializer::class); |
||
| 270 | $this->app->bind(DenormalizerInterface::class, Serializer::class); |
||
| 271 | |||
| 272 | $todo = [ |
||
| 273 | [ApiResourceFacade::class, 'getApiResourceFacade'], |
||
| 274 | [ClassResourceConverter::class, 'getClassResourceConverter'], |
||
| 275 | [OpenApiSpecGenerator::class, 'getOpenApiSpecGenerator'], |
||
| 276 | [ResourceSerializerInterface::class, 'getResourceSerializer'], |
||
| 277 | [NameConverterInterface::class, 'getPropertyConverter'], |
||
| 278 | [ObjectAccessInterface::class, 'getObjectAccess'] |
||
| 279 | ]; |
||
| 280 | while ($item = array_pop($todo)) { |
||
| 281 | $this->registerApieService($item[0], $item[1]); |
||
| 282 | } |
||
| 303 |
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