Passed
Branch develop (d49db1)
by Baptiste
01:49
created

Lazy::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose;
5
6
use Innmind\Compose\{
7
    Definition\Name,
8
    Exception\ReferenceNotFound
9
};
10
11
final class Lazy
12
{
13
    private $name;
14
    private $definitions;
15
16 58
    public function __construct(
17
        Name $name,
18
        Definitions $definitions
19
    ) {
20 58
        if (!$definitions->has($name)) {
21 1
            throw new ReferenceNotFound((string) $name);
22
        }
23
24 57
        $this->name = $name;
25 57
        $this->definitions = $definitions;
26 57
    }
27
28 48
    public function load(): object
29
    {
30 48
        return $this->definitions->build($this->name);
31
    }
32
}
33