Conditions | 6 |
Paths | 16 |
Total Lines | 76 |
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 |
||
61 | public function load(array $configs, ContainerBuilder $container) |
||
62 | { |
||
63 | $config = $this->processConfiguration( |
||
64 | $this->getConfiguration($configs, $container), |
||
|
|||
65 | $configs |
||
66 | ); |
||
67 | |||
68 | if (interface_exists(MimeTypeGuesserInterface::class)) { |
||
69 | $mimeTypes = new Definition(MimeTypes::class); |
||
70 | $mimeTypes->setFactory([MimeTypes::class, 'getDefault']); |
||
71 | |||
72 | $container->setDefinition('liip_imagine.mime_types', $mimeTypes); |
||
73 | } |
||
74 | |||
75 | $container->setParameter('liip_imagine.resolvers', $config['resolvers']); |
||
76 | $container->setParameter('liip_imagine.loaders', $config['loaders']); |
||
77 | |||
78 | $this->loadResolvers($config['resolvers'], $container); |
||
79 | $this->loadLoaders($config['loaders'], $container); |
||
80 | |||
81 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
82 | $loader->load('imagine.xml'); |
||
83 | $loader->load('commands.xml'); |
||
84 | |||
85 | if ($config['enqueue']) { |
||
86 | $loader->load('enqueue.xml'); |
||
87 | } |
||
88 | |||
89 | if ($config['templating']) { |
||
90 | $loader->load('templating.xml'); |
||
91 | } |
||
92 | |||
93 | $container->setParameter('liip_imagine.driver_service', 'liip_imagine.'.$config['driver']); |
||
94 | |||
95 | $container |
||
96 | ->getDefinition('liip_imagine.controller.config') |
||
97 | ->replaceArgument(0, $config['controller']['redirect_response_code']); |
||
98 | |||
99 | $container->setAlias('liip_imagine', new Alias('liip_imagine.'.$config['driver'])); |
||
100 | $container->setAlias(CacheManager::class, new Alias('liip_imagine.cache.manager', false)); |
||
101 | $container->setAlias(DataManager::class, new Alias('liip_imagine.data.manager', false)); |
||
102 | $container->setAlias(FilterManager::class, new Alias('liip_imagine.filter.manager', false)); |
||
103 | |||
104 | $container->setParameter('liip_imagine.cache.resolver.default', $config['cache']); |
||
105 | |||
106 | $container->setParameter('liip_imagine.default_image', $config['default_image']); |
||
107 | |||
108 | $filterSets = $this->createFilterSets($config['default_filter_set_settings'], $config['filter_sets']); |
||
109 | |||
110 | $container->setParameter('liip_imagine.filter_sets', $filterSets); |
||
111 | $container->setParameter('liip_imagine.binary.loader.default', $config['data_loader']); |
||
112 | |||
113 | $container->setParameter('liip_imagine.controller.filter_action', $config['controller']['filter_action']); |
||
114 | $container->setParameter('liip_imagine.controller.filter_runtime_action', $config['controller']['filter_runtime_action']); |
||
115 | |||
116 | $container->setParameter('twig.form.resources', array_merge( |
||
117 | $container->hasParameter('twig.form.resources') ? $container->getParameter('twig.form.resources') : [], |
||
118 | ['@LiipImagine/Form/form_div_layout.html.twig'] |
||
119 | )); |
||
120 | |||
121 | if ($container->hasDefinition('liip_imagine.mime_types')) { |
||
122 | $mimeTypes = $container->getDefinition('liip_imagine.mime_types'); |
||
123 | $container->getDefinition('liip_imagine.binary.mime_type_guesser') |
||
124 | ->replaceArgument(0, $mimeTypes); |
||
125 | |||
126 | $container->getDefinition('liip_imagine.data.manager') |
||
127 | ->replaceArgument(1, $mimeTypes); |
||
128 | } |
||
129 | |||
130 | $this->deprecationTemplatingFilterHelper($container); |
||
131 | |||
132 | $container->setParameter('liip_imagine.webp.generate', $config['webp']['generate']); |
||
133 | $webpOptions = $config['webp']; |
||
134 | unset($webpOptions['generate']); |
||
135 | $container->setParameter('liip_imagine.webp.options', $webpOptions); |
||
136 | } |
||
137 | |||
178 |
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: