Completed
Push — develop ( 5a8a22...72aeee )
by Baptiste
02:16
created

ContainerBuilder::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\ContainerBuilder;
5
6
use Innmind\Compose\{
7
    ContainerBuilder as ContainerBuilderInterface,
8
    Container,
9
    Loader
10
};
11
use Innmind\Url\PathInterface;
12
use Innmind\Immutable\MapInterface;
13
use Psr\Container\ContainerInterface;
14
15
final class ContainerBuilder implements ContainerBuilderInterface
16
{
17
    private $load;
18
19 1
    public function __construct(Loader $loader)
20
    {
21 1
        $this->load = $loader;
22 1
    }
23
24
    /**
25
     * @param MapInterface<string, mixed> $arguments
26
     */
27 1
    public function __invoke(
28
        PathInterface $definition,
29
        MapInterface $arguments
30
    ): ContainerInterface {
31 1
        $services = ($this->load)($definition);
32
33 1
        return new Container($services->inject($arguments));
34
    }
35
}
36