Loader   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A loadFromDirectory() 0 4 1
A loadFiles() 0 18 3
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