Completed
Push — master ( ab3484...e9fb28 )
by Woody
9s
created

LazyInjectorBuilder::build()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 6
cts 6
cp 1
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 1
crap 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Container;
5
6
use Auryn\Injector;
7
8
class LazyInjectorBuilder
9
{
10
    /** @var string[] */
11
    private $configs;
12
13
    /**
14
     * @param string[] $configs
15
     */
16 2
    public function __construct(array $configs = [])
17
    {
18 2
        $this->configs = $configs;
19 2
    }
20
21
    /**
22
     * Build the injector using the provided configuration.
23
     */
24 2 View Code Duplication
    public function build(Injector $injector = null): Injector
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26 2
        if (empty($injector)) {
27 2
            $injector = new Injector();
28
        }
29
30 2
        foreach ($this->configs as $config) {
31 2
            $this->makeConfig($injector, $config)->apply($injector);
32
        }
33
34 2
        return $injector;
35
    }
36
37 2
    private function makeConfig(Injector $injector, string $config): InjectorConfig
38
    {
39 2
        return $injector->make($config);
40
    }
41
}
42