InfrastructureLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A load() 0 9 1
1
<?php
2
3
namespace Assimtech\Tempo\Loader;
4
5
use Symfony\Component\Yaml;
6
use Assimtech\Tempo\Factory\InfrastructureFactory;
7
8
class InfrastructureLoader extends AbstractLoader
9
{
10
    /**
11
     * @var \Assimtech\Tempo\Factory\InfrastructureFactory $factory
12
     */
13
    private $factory;
14
15
    /**
16
     * @var \Symfony\Component\Yaml\Parser $yamlParser
17
     */
18
    private $yamlParser;
19
20
    /**
21
     * @param \Assimtech\Tempo\Factory\InfrastructureFactory $factory
22
     * @param \Symfony\Component\Yaml\Parser $yamlParser
23
     */
24 5
    public function __construct(InfrastructureFactory $factory, Yaml\Parser $yamlParser)
25
    {
26 5
        $this->factory = $factory;
27 5
        $this->yamlParser = $yamlParser;
28 5
    }
29
30
    /**
31
     * @param string $path The path to a file defining \Assimtech\Tempo\Infrastructure
32
     *      defaults to 'tempo/infrastructure.yml'
33
     * @return \Assimtech\Tempo\Infrastructure
34
     */
35 3
    public function load($path)
36
    {
37 3
        $this->validatePath($path);
38 1
        $yaml = file_get_contents($path);
39 1
        $config = $this->yamlParser->parse($yaml);
40 1
        $infrastructure = $this->factory->create($config);
41
42 1
        return $infrastructure;
43
    }
44
}
45