Completed
Push — 2.x ( f6f39e...3155fc )
by Akihito
18s queued 15s
created

ProviderProvider::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di;
6
7
use Ray\Di\Di\Set;
8
9
/**
10
 * @implements ProviderInterface<mixed>
11
 * @template T of object
12
 */
13
final class ProviderProvider implements ProviderInterface
14
{
15
    /** @var InjectorInterface  */
16
    private $injector;
17
18
    /** @var Set<T> */
19
    private $set;
20
21
    /** @param Set<T> $set */
22
    public function __construct(InjectorInterface $injector, Set $set)
23
    {
24
        $this->injector = $injector;
25
        $this->set = $set;
26
    }
27
28
    /** @return mixed */
29
    public function get()
30
    {
31
        return $this->injector->getInstance($this->set->interface, $this->set->name);
32
    }
33
}
34