Passed
Branch v0.2 (3b8de8)
by Freddie
05:06
created

CoreDefinitionLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A load() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Simplex\DefinitionLoader;
4
5
use DI\ContainerBuilder;
6
7
class CoreDefinitionLoader implements DefinitionLoader
8
{
9
    const DEFAULT_DEFINITION_FILE = __DIR__ . '/../config/services.php';
10
11
    /** @var \SplFileInfo */
12
    private $coreDefinitionsFile;
13
14
    public function __construct(\SplFileInfo $coreDefinitionsFile = null)
15
    {
16
        if (null === $coreDefinitionsFile) {
17
            $this->coreDefinitionsFile = new \SplFileInfo(self::DEFAULT_DEFINITION_FILE);
18
            return;
19
        }
20
21
        $this->coreDefinitionsFile = $coreDefinitionsFile;
22
    }
23
24
    public function load(ContainerBuilder $containerBuilder): void
25
    {
26
        $containerBuilder->addDefinitions($this->coreDefinitionsFile->getPathname());
27
    }
28
}
29