Conditions | 5 |
Paths | 8 |
Total Lines | 61 |
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 | $filterSets = $this->createFilterSets($config['default_filter_set_settings'], $config['filter_sets']); |
||
110 | |||
111 | $container->setParameter('liip_imagine.filter_sets', $filterSets); |
||
112 | $container->setParameter('liip_imagine.binary.loader.default', $config['data_loader']); |
||
113 | |||
114 | $container->setParameter('liip_imagine.controller.filter_action', $config['controller']['filter_action']); |
||
115 | $container->setParameter('liip_imagine.controller.filter_runtime_action', $config['controller']['filter_runtime_action']); |
||
116 | |||
117 | $container->setParameter('twig.form.resources', array_merge( |
||
118 | $container->hasParameter('twig.form.resources') ? $container->getParameter('twig.form.resources') : [], |
||
119 | ['@LiipImagine/Form/form_div_layout.html.twig'] |
||
120 | )); |
||
121 | |||
122 | if ($container->hasDefinition('liip_imagine.mime_types')) { |
||
123 | $mimeTypes = $container->getDefinition('liip_imagine.mime_types'); |
||
124 | $container->getDefinition('liip_imagine.binary.mime_type_guesser') |
||
125 | ->replaceArgument(0, $mimeTypes); |
||
126 | |||
127 | $container->getDefinition('liip_imagine.data.manager') |
||
128 | ->replaceArgument(1, $mimeTypes); |
||
129 | } |
||
130 | } |
||
131 | |||
169 |
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: