Conditions | 10 |
Paths | 96 |
Total Lines | 54 |
Code Lines | 30 |
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 | if (false === empty($fixtureBundles)) { |
||
160 | $fixturesFiles = array_merge( |
||
161 | $fixturesFiles, |
||
162 | $this->getFixturesFinder()->getFixtures($this->kernel, $fixtureBundles, $this->kernel->getEnvironment()) |
||
163 | ); |
||
164 | } |
||
165 | |||
166 | if (false === empty($fixtureDirectories)) { |
||
167 | $fixturesFiles = array_merge( |
||
168 | $fixturesFiles, |
||
169 | $this->getFixturesFinder()->getFixturesFromDirectory($fixtureDirectories) |
||
170 | ); |
||
171 | } |
||
172 | |||
173 | $this->getLoader()->load( |
||
174 | $persister, |
||
175 | $this->getFixturesFinder()->resolveFixtures($this->kernel, $fixturesFiles) |
||
176 | ); |
||
177 | } |
||
178 | |||
224 |