Completed
Push — master ( fcd824...b6bffc )
by Yann
07:28 queued 03:56
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
        foreach ($fixtures as $fixture) {
35
            $spec = array_map(function ($property) {
36
                return $property->getValue();
37
            }, $fixture->getProperties());
38
39
            $this->cache[] = [ $spec, $this->objects->get($fixture->getName()) ];
40
        }
41
    }
42
}
43