| Conditions | 5 |
| Paths | 8 |
| Total Lines | 59 |
| 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 |
||
| 70 | public function load(array $configs, ContainerBuilder $container) |
||
| 71 | { |
||
| 72 | $config = $this->processConfiguration( |
||
| 73 | $this->getConfiguration($configs, $container), |
||
|
|
|||
| 74 | $configs |
||
| 75 | ); |
||
| 76 | |||
| 77 | if (interface_exists(MimeTypeGuesserInterface::class)) { |
||
| 78 | $mimeTypes = new Definition(MimeTypes::class); |
||
| 79 | $mimeTypes->setFactory([MimeTypes::class, 'getDefault']); |
||
| 80 | |||
| 81 | $container->setDefinition('liip_imagine.mime_types', $mimeTypes); |
||
| 82 | } |
||
| 83 | |||
| 84 | $container->setParameter('liip_imagine.resolvers', $config['resolvers']); |
||
| 85 | $container->setParameter('liip_imagine.loaders', $config['loaders']); |
||
| 86 | |||
| 87 | $this->loadResolvers($config['resolvers'], $container); |
||
| 88 | $this->loadLoaders($config['loaders'], $container); |
||
| 89 | |||
| 90 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
| 91 | $loader->load('imagine.xml'); |
||
| 92 | $loader->load('commands.xml'); |
||
| 93 | |||
| 94 | if ($config['enqueue']) { |
||
| 95 | $loader->load('enqueue.xml'); |
||
| 96 | } |
||
| 97 | |||
| 98 | $container->setParameter('liip_imagine.driver_service', 'liip_imagine.'.$config['driver']); |
||
| 99 | |||
| 100 | $container->setAlias('liip_imagine', new Alias('liip_imagine.'.$config['driver'])); |
||
| 101 | $container->setAlias(CacheManager::class, new Alias('liip_imagine.cache.manager', false)); |
||
| 102 | $container->setAlias(DataManager::class, new Alias('liip_imagine.data.manager', false)); |
||
| 103 | $container->setAlias(FilterManager::class, new Alias('liip_imagine.filter.manager', false)); |
||
| 104 | |||
| 105 | $container->setParameter('liip_imagine.cache.resolver.default', $config['cache']); |
||
| 106 | |||
| 107 | $container->setParameter('liip_imagine.default_image', $config['default_image']); |
||
| 108 | |||
| 109 | $container->setParameter('liip_imagine.filter_sets', $config['filter_sets']); |
||
| 110 | $container->setParameter('liip_imagine.binary.loader.default', $config['data_loader']); |
||
| 111 | |||
| 112 | $container->setParameter('liip_imagine.controller.filter_action', $config['controller']['filter_action']); |
||
| 113 | $container->setParameter('liip_imagine.controller.filter_runtime_action', $config['controller']['filter_runtime_action']); |
||
| 114 | |||
| 115 | $container->setParameter('twig.form.resources', array_merge( |
||
| 116 | $container->hasParameter('twig.form.resources') ? $container->getParameter('twig.form.resources') : [], |
||
| 117 | ['@LiipImagine/Form/form_div_layout.html.twig'] |
||
| 118 | )); |
||
| 119 | |||
| 120 | if ($container->hasDefinition('liip_imagine.mime_types')) { |
||
| 121 | $mimeTypes = $container->getDefinition('liip_imagine.mime_types'); |
||
| 122 | $container->getDefinition('liip_imagine.binary.mime_type_guesser') |
||
| 123 | ->replaceArgument(0, $mimeTypes); |
||
| 124 | |||
| 125 | $container->getDefinition('liip_imagine.data.manager') |
||
| 126 | ->replaceArgument(1, $mimeTypes); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 160 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: