| Conditions | 11 |
| Paths | 80 |
| Total Lines | 57 |
| Code Lines | 36 |
| 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 declare(strict_types=1); |
||
| 26 | public function load(array $configs, ContainerBuilder $container) |
||
| 27 | { |
||
| 28 | $config = $this->processConfiguration(new Configuration(), $configs); |
||
| 29 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
||
| 30 | $loader->load('services.yml'); |
||
| 31 | |||
| 32 | if ($config['handle_exceptions']) { |
||
| 33 | $loader->load('listener_exception.yml'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $container->setParameter('swagger.document.base_path', $config['document']['base_path']); |
||
| 37 | $container->setParameter('phpapi.router_name', 'swagger'); |
||
| 38 | |||
| 39 | if (isset($config['document']['cache'])) { |
||
| 40 | $resolverDefinition = $container->getDefinition('swagger.description.repository'); |
||
| 41 | $resolverDefinition->addArgument(new Reference($config['document']['cache'])); |
||
| 42 | } |
||
| 43 | $responseFactory = $container->getDefinition('swagger.response.factory'); |
||
| 44 | |||
| 45 | if (isset($config['hydrator'])) { |
||
| 46 | $container |
||
| 47 | ->getDefinition('swagger.hydrator.class_name_resolver') |
||
| 48 | ->replaceArgument(0, $config['hydrator']['namespaces']); |
||
| 49 | |||
| 50 | $dateTimeSerializerDefinition = $container->getDefinition('swagger.hydrator.class_name_resolver'); |
||
| 51 | if (isset($config['hydrator']['date_formats'])) { |
||
| 52 | foreach ($config['hydrator']['date_formats'] as $format) { |
||
| 53 | $predefinedFormat = DateTimeSerializer::class . "::FORMAT_{$format}"; |
||
| 54 | if (defined($predefinedFormat)) { |
||
| 55 | $format = constant($predefinedFormat); |
||
| 56 | } |
||
| 57 | $dateTimeSerializerDefinition->addArgument(new Reference($format)); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | $builderDefinition = $container->getDefinition('swagger.hydrator.processor.builder'); |
||
| 62 | |||
| 63 | if (isset($config['hydrator']['processors'])) { |
||
| 64 | foreach ($config['hydrator']['processors'] as $processor) { |
||
| 65 | $builderDefinition->addMethodCall('add', new Reference($processor)); |
||
|
|
|||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | $hydrator = new Reference('swagger.hydrator'); |
||
| 70 | $definition = $container->getDefinition('swagger.request.processor'); |
||
| 71 | $definition->addArgument($hydrator); |
||
| 72 | $responseFactory->replaceArgument(0, $hydrator); |
||
| 73 | } |
||
| 74 | if ($config['validate_responses']) { |
||
| 75 | $responseFactory->addArgument(new Reference('swagger.request.validator')); |
||
| 76 | } |
||
| 77 | if ($config['ok_status_resolver']) { |
||
| 78 | $responseFactory->addArgument(new Reference($config['ok_status_resolver'])); |
||
| 79 | } |
||
| 80 | |||
| 81 | $container->setParameter('swagger.match_unsecured', $config['security']['match_unsecured']); |
||
| 82 | } |
||
| 83 | |||
| 92 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: