Loader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 5
1
<?php
2
3
namespace Ck\Laravel\Alice\Loader;
4
5
use Ck\Laravel\Alice\Populator\Methods\AttributePopulator;
6
use Nelmio\Alice\Instances\Populator\Populator;
7
use Nelmio\Alice\PersisterInterface;
8
9
class Loader extends \Nelmio\Alice\Fixtures\Loader
10
{
11
    public function __construct(PersisterInterface $persister, $locale, array $providers, $seed, array $parameters)
12
    {
13
        $this->manager = $persister;
14
15
        parent::__construct($locale, $providers, $seed, $parameters);
16
17
        $this->populator = new Populator(
18
            $this->objects,
19
            $this->processor,
20
            array(
21
                new AttributePopulator()
22
            )
23
        );
24
    }
25
26
    public function loadFromDirectory($path)
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
29
    }
30
31
    public function loadFiles($fixtures)
32
    {
33
        $objects = [];
34
35
        foreach ($fixtures as $fixture) {
36
            if (!file_exists($fixture)) {
37
                throw new \InvalidArgumentException('The file could not be found: '.$fixture);
38
            }
39
40
            $set = $this->load($fixture);
41
42
            $objects = array_merge($objects, $set);
43
        }
44
45
        $this->manager->persist($objects);
46
47
        return $objects;
48
    }
49
}
50