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

LazyInjectorBuilder::makeConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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