Passed
Push — master ( 81686d...1595cb )
by Kirill
04:41
created

VariableValueNode   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 8
dl 0
loc 56
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 3 1
A toPHPValue() 0 3 1
A __construct() 0 3 1
A getName() 0 3 1
A __toString() 0 3 1
A toString() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Frontend\Ast\Value;
13
14
use Railt\SDL\Frontend\Ast\Node;
15
use Railt\TypeSystem\Value\NullValue;
16
use Railt\TypeSystem\Value\ValueInterface;
17
18
/**
19
 * Class VariableValueNode
20
 */
21
class VariableValueNode extends Node implements ValueInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private string $name;
27
28
    /**
29
     * VariableValue constructor.
30
     *
31
     * @param string $name
32
     */
33
    public function __construct(string $name)
34
    {
35
        $this->name = $name;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getName(): string
42
    {
43
        return $this->name;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function toString(): string
50
    {
51
        return '$' . $this->name;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function __toString(): string
58
    {
59
        return $this->toString();
60
    }
61
62
    /**
63
     * @param mixed $value
64
     * @return ValueInterface
65
     */
66
    public static function parse($value): ValueInterface
67
    {
68
        return new static((string)$value);
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74
    public function toPHPValue()
75
    {
76
        return $this->getName();
77
    }
78
}
79