Conditions | 16 |
Paths | 712 |
Total Lines | 46 |
Code Lines | 28 |
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 |
||
130 | protected function fixConfiguration(array $config) |
||
131 | { |
||
132 | foreach ($config['sitemap']['doctrine_orm'] as $pos => $sitemap) { |
||
133 | $sitemap['group'] = isset($sitemap['group']) ? $sitemap['group'] : false; |
||
134 | $sitemap['types'] = isset($sitemap['types']) ? $sitemap['types'] : []; |
||
135 | $sitemap['connection'] = isset($sitemap['connection']) ? $sitemap['connection'] : 'doctrine.dbal.default_connection'; |
||
136 | $sitemap['route'] = isset($sitemap['route']) ? $sitemap['route'] : false; |
||
137 | $sitemap['parameters'] = isset($sitemap['parameters']) ? $sitemap['parameters'] : false; |
||
138 | $sitemap['query'] = isset($sitemap['query']) ? $sitemap['query'] : false; |
||
139 | |||
140 | if ($sitemap['route'] === false) { |
||
141 | throw new \RuntimeException('Route cannot be empty, please review the sonata_seo.sitemap configuration'); |
||
142 | } |
||
143 | |||
144 | if ($sitemap['query'] === false) { |
||
145 | throw new \RuntimeException('Query cannot be empty, please review the sonata_seo.sitemap configuration'); |
||
146 | } |
||
147 | |||
148 | if ($sitemap['parameters'] === false) { |
||
149 | throw new \RuntimeException('Route\'s parameters cannot be empty, please review the sonata_seo.sitemap configuration'); |
||
150 | } |
||
151 | |||
152 | $config['sitemap']['doctrine_orm'][$pos] = $sitemap; |
||
153 | } |
||
154 | |||
155 | foreach ($config['sitemap']['services'] as $pos => $sitemap) { |
||
156 | if (!is_array($sitemap)) { |
||
157 | $sitemap = [ |
||
158 | 'group' => false, |
||
159 | 'types' => [], |
||
160 | 'id' => $sitemap, |
||
161 | ]; |
||
162 | } else { |
||
163 | $sitemap['group'] = isset($sitemap['group']) ? $sitemap['group'] : false; |
||
164 | $sitemap['types'] = isset($sitemap['types']) ? $sitemap['types'] : []; |
||
165 | |||
166 | if (!isset($sitemap['id'])) { |
||
167 | throw new \RuntimeException('Service id must to be defined, please review the sonata_seo.sitemap configuration'); |
||
168 | } |
||
169 | } |
||
170 | |||
171 | $config['sitemap']['services'][$pos] = $sitemap; |
||
172 | } |
||
173 | |||
174 | return $config; |
||
175 | } |
||
176 | } |
||
177 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.