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

Lazy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A load() 0 3 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