| Conditions | 10 |
| Paths | 96 |
| Total Lines | 54 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 167 | private function loadFixtures($fixturesFiles, $persister = null) |
||
| 168 | { |
||
| 169 | if (null === $persister) { |
||
| 170 | $persister = $this->persister; |
||
| 171 | } |
||
| 172 | |||
| 173 | if (true === is_string($persister)) { |
||
| 174 | $persister = $this->castServiceIdToPersister($persister); |
||
| 175 | } |
||
| 176 | |||
| 177 | $fixtureBundles = []; |
||
| 178 | $fixtureDirectories = []; |
||
| 179 | |||
| 180 | foreach ($fixturesFiles as $key => $fixturesFile) { |
||
| 181 | if (0 === strpos($fixturesFile, '/')) { |
||
| 182 | if (is_dir($fixturesFile)) { |
||
| 183 | $fixtureDirectories[] = $fixturesFile; |
||
| 184 | unset($fixturesFiles[$key]); |
||
| 185 | } |
||
| 186 | |||
| 187 | continue; |
||
| 188 | } |
||
| 189 | |||
| 190 | if (0 === strpos($fixturesFile, '@')) { |
||
| 191 | if (false === strpos($fixturesFile, '.')) { |
||
| 192 | $fixtureBundles[] = $this->kernel->getBundle(substr($fixturesFile, 1)); |
||
| 193 | unset($fixturesFiles[$key]); |
||
| 194 | } |
||
| 195 | |||
| 196 | continue; |
||
| 197 | } |
||
| 198 | |||
| 199 | $fixturesFiles[$key] = sprintf('%s/%s', $this->basePath, $fixturesFile); |
||
| 200 | } |
||
| 201 | |||
| 202 | if (false === empty($fixtureBundles)) { |
||
| 203 | $fixturesFiles = array_merge( |
||
| 204 | $fixturesFiles, |
||
| 205 | $this->fixturesFinder->getFixtures($this->kernel, $fixtureBundles, $this->kernel->getEnvironment()) |
||
| 206 | ); |
||
| 207 | } |
||
| 208 | |||
| 209 | if (false === empty($fixtureDirectories)) { |
||
| 210 | $fixturesFiles = array_merge( |
||
| 211 | $fixturesFiles, |
||
| 212 | $this->fixturesFinder->getFixturesFromDirectory($fixtureDirectories) |
||
|
|
|||
| 213 | ); |
||
| 214 | } |
||
| 215 | |||
| 216 | $this->loader->load( |
||
| 217 | $persister, |
||
| 218 | $this->fixturesFinder->resolveFixtures($this->kernel, $fixturesFiles) |
||
| 219 | ); |
||
| 220 | } |
||
| 221 | |||
| 249 |
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: