Completed
Push — sam-rework ( 1696e6 )
by Andrii
38:13 queued 23:11
created

ValueDependency   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getId() 0 3 1
A resolve() 0 3 1
1
<?php
2
3
4
namespace yii\di\dependencies;
5
6
use Psr\Container\ContainerInterface;
7
use yii\di\Container;
8
use yii\di\contracts\DependencyInterface;
9
10
class ValueDependency implements DependencyInterface
11
{
12
    private $value;
13
14
    public function __construct($value)
15
    {
16
        $this->value = $value;
17
    }
18
19
    /**
20
     * @param Container $container
21
     */
22
    public function resolve(ContainerInterface $container)
23
    {
24
        return $this->value;
25
    }
26
27
    /**
28
     * This is used to detect circular reference.
29
     * If a concrete reference is guaranteed to never be part of such a circle
30
     * (for example because it references a simple value) NULL should be returned
31
     * @return string|null A string uniquely identifying a service in the container
32
     */
33
    public function getId(): ?string
34
    {
35
        return null;
36
    }
37
}
38