Passed
Push — multi_binding ( 75a5e8 )
by Akihito
02:09
created

Lazy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\MultiBinding;
6
7
use Ray\Di\InjectorInterface;
8
9
final class Lazy
10
{
11
    /** @var class-string */
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
12
    private $class;
13
14
    /**
15
     * @param class-string $class
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
16
     */
17
    public function __construct(string $class)
18
    {
19
        $this->class = $class;
20
    }
21
22
    /**
23
     * @return mixed
24
     */
25
    public function __invoke(InjectorInterface $injector)
26
    {
27
        return $injector->getInstance($this->class);
28
    }
29
}
30