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

ProviderProvider   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 6
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 3 1
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