Completed
Pull Request — master (#12)
by Woody
05:04
created

InjectorBuilder::applicator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Container;
5
6
use Auryn\Injector;
7
8
class InjectorBuilder
9
{
10
    /** @var InjectorConfig[] */
11
    private $configs;
12
13
    /**
14
     * @param InjectorConfig[] $configs
15
     */
16 3
    public function __construct(array $configs = [])
17
    {
18 3
        $this->configs = $configs;
19 3
    }
20
21
    /**
22
     * Build the injector using the provided configuration.
23
     */
24 3
    public function build(Injector $injector = null): Injector
25
    {
26 3
        if ($injector === null) {
27 2
            $injector = new Injector();
28
        }
29
30 3
        foreach ($this->configs as $config) {
31 2
            $config->apply($injector);
32
        }
33
34 3
        return $injector;
35
    }
36
}
37