Passed
Push — master ( 72c793...7f699f )
by Kirill
03:22
created

ValueDependency::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Views\Context;
13
14
use Spiral\Views\DependencyInterface;
15
16
/**
17
 * Fixed value dependency.
18
 */
19
final class ValueDependency implements DependencyInterface
20
{
21
    /** @var string */
22
    private $name;
23
24
    /** @var mixed */
25
    private $value;
26
27
    /** @var array */
28
    private $variants;
29
30
    /**
31
     * @param string $name
32
     * @param mixed  $value
33
     * @param array  $variants
34
     */
35
    public function __construct(string $name, $value, array $variants = null)
36
    {
37
        $this->name = $name;
38
        $this->value = $value;
39
        $this->variants = $variants ?? [$value];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function getName(): string
46
    {
47
        return $this->name;
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function getValue()
54
    {
55
        return $this->value;
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function getVariants(): array
62
    {
63
        return $this->variants;
64
    }
65
}
66