Completed
Pull Request — master (#160)
by
unknown
04:47
created

Loader::getCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Knp\FriendlyContexts\Alice\Fixtures;
4
5
use Knp\FriendlyContexts\Alice\ProviderResolver;
6
use Nelmio\Alice\Fixtures\Loader as BaseLoader;
7
8
class Loader extends BaseLoader
9
{
10
    private $cache = [];
11
12
    public function __construct($locale, ProviderResolver $providers)
13
    {
14
        parent::__construct($locale, $providers->all());
15
    }
16
17
    public function getCache()
18
    {
19
        return $this->cache;
20
    }
21
22
    public function clearCache()
23
    {
24
        $this->cache = [];
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function instantiateFixtures(array $fixtures)
31
    {
32
        parent::instantiateFixtures($fixtures);
33
34
        /** @var \Nelmio\Alice\Fixtures\Fixture $fixture */
35
        foreach ($fixtures as $fixture) {
36
            /** @var \Nelmio\Alice\Fixtures\PropertyDefinition $property */
37
            $spec = array_map(function ($property) {
38
                return $property->getValue();
39
            }, $fixture->getProperties());
40
41
            $this->cache[] = [ $spec, $this->objects->get($fixture->getName()) ];
42
        }
43
    }
44
}
45