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

Lazy::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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