| Total Complexity | 9 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Loader extends NativeLoader implements |
||
| 10 | LoaderInterface |
||
| 11 | { |
||
| 12 | private $fixtureSet; |
||
| 13 | private $fixtureData; |
||
| 14 | private $loader; |
||
| 15 | private $dataLoader; |
||
| 16 | |||
| 17 | public function __construct() |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getCache() |
||
| 26 | { |
||
| 27 | $fixtureSet = $this->dataLoader->getLastFixtureSet(); |
||
| 28 | if (null === $fixtureSet) { |
||
| 29 | return array(); |
||
| 30 | } |
||
| 31 | |||
| 32 | $cache = array(); |
||
| 33 | $fixtures = $fixtureSet->getFixtures(); |
||
| 34 | foreach ($fixtures as $fixture) { |
||
| 35 | $spec = array(); |
||
| 36 | |||
| 37 | $properties = $fixture->getSpecs()->getProperties(); |
||
| 38 | foreach ($properties->getIterator() as $property) { |
||
| 39 | $spec[] = $property->getValue(); |
||
| 40 | } |
||
| 41 | |||
| 42 | $cache[] = [$spec, $this->fixtureData[$fixture->getId()]]; |
||
| 43 | } |
||
| 44 | |||
| 45 | return $cache; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function clearCache() |
||
| 49 | { |
||
| 50 | $this->fixtureSet = null; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function load($filename) |
||
| 54 | { |
||
| 55 | if ( ! is_array($filename)) { |
||
| 56 | $filename = array($filename); |
||
| 57 | } |
||
| 58 | return $this->loader->loadFiles($filename)->getObjects(); |
||
| 59 | } |
||
| 60 | |||
| 61 | protected function createDataLoader() : DataLoaderInterface |
||
| 66 | ); |
||
| 67 | } |
||
| 68 | } |
||
| 69 |