| Conditions | 10 |
| Paths | 96 |
| Total Lines | 56 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 124 | private function loadFixtures($fixturesFiles, $persister = null) |
||
| 125 | { |
||
| 126 | if (null === $persister) { |
||
| 127 | $persister = $this->getPersister(); |
||
|
|
|||
| 128 | } |
||
| 129 | |||
| 130 | if (true === is_string($persister)) { |
||
| 131 | $persister = $this->castServiceIdToPersister($persister); |
||
| 132 | } |
||
| 133 | |||
| 134 | $fixtureBundles = []; |
||
| 135 | $fixtureDirectories = []; |
||
| 136 | |||
| 137 | foreach ($fixturesFiles as $key => $fixturesFile) { |
||
| 138 | if (0 === strpos($fixturesFile, '/')) { |
||
| 139 | if (is_dir($fixturesFile)) { |
||
| 140 | $fixtureDirectories[] = $fixturesFile; |
||
| 141 | unset($fixturesFiles[$key]); |
||
| 142 | } |
||
| 143 | |||
| 144 | continue; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (0 === strpos($fixturesFile, '@')) { |
||
| 148 | if (false === strpos($fixturesFile, '.')) { |
||
| 149 | $fixtureBundles[] = $this->kernel->getBundle(substr($fixturesFile, 1)); |
||
| 150 | unset($fixturesFiles[$key]); |
||
| 151 | } |
||
| 152 | |||
| 153 | continue; |
||
| 154 | } |
||
| 155 | |||
| 156 | $fixturesFiles[$key] = sprintf('%s/%s', $this->basePath, $fixturesFile); |
||
| 157 | } |
||
| 158 | |||
| 159 | $fixturesFinder = $this->getFixturesFinder(); |
||
| 160 | |||
| 161 | if (false === empty($fixtureBundles)) { |
||
| 162 | $fixturesFiles = array_merge( |
||
| 163 | $fixturesFiles, |
||
| 164 | $fixturesFinder->getFixtures($this->kernel, $fixtureBundles, $this->kernel->getEnvironment()) |
||
| 165 | ); |
||
| 166 | } |
||
| 167 | |||
| 168 | if (false === empty($fixtureDirectories)) { |
||
| 169 | $fixturesFiles = array_merge( |
||
| 170 | $fixturesFiles, |
||
| 171 | $fixturesFinder->getFixturesFromDirectory($fixtureDirectories) |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | |||
| 175 | $this->getLoader()->load( |
||
| 176 | $persister, |
||
| 177 | $fixturesFinder->resolveFixtures($this->kernel, $fixturesFiles) |
||
| 178 | ); |
||
| 179 | } |
||
| 180 | |||
| 226 |