Passed
Push — master ( 9b9be7...468f99 )
by Dan
04:07 queued 10s
created

DataLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A loadData() 0 4 1
A getLastFixtureSet() 0 3 1
1
<?php
2
3
namespace Knp\FriendlyContexts\Alice\Fixtures\Alice3;
4
5
use Nelmio\Alice\DataLoaderInterface;
6
use Nelmio\Alice\FixtureBuilderInterface;
7
use Nelmio\Alice\FixtureSet;
8
use Nelmio\Alice\GeneratorInterface;
9
use Nelmio\Alice\IsAServiceTrait;
10
use Nelmio\Alice\ObjectSet;
11
12
/**
13
 * Class SimpleDataLoader
14
 *
15
 * Data loader for use with Alice3
16
 *
17
 * @package Knp\FriendlyContexts\Alice\Fixtures
18
 */
19
class DataLoader implements DataLoaderInterface
20
{
21
    use IsAServiceTrait;
22
23
    /**
24
     * @var FixtureBuilderInterface
25
     */
26
    private $builder;
27
28
    /**
29
     * @var GeneratorInterface
30
     */
31
    private $generator;
32
33
    /**
34
     * @var null|FixtureSet
35
     */
36
    private $lastFixtureSet = null;
37
38
    public function __construct(FixtureBuilderInterface $fixtureBuilder, GeneratorInterface $generator)
39
    {
40
        $this->builder = $fixtureBuilder;
41
        $this->generator = $generator;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function loadData(array $data, array $parameters = array(), array $objects = array()) : ObjectSet
48
    {
49
        $this->lastFixtureSet = $this->builder->build($data, $parameters, $objects);
50
        return $this->generator->generate($this->lastFixtureSet);
51
    }
52
53
    /**
54
     * @internal
55
     */
56
    public function getLastFixtureSet()
57
    {
58
        return $this->lastFixtureSet;
59
    }
60
}