Test Failed
Push — master ( b7ab7b...94ee03 )
by Kirill
02:59
created

Value   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 49
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A getValue() 0 4 1
A getType() 0 4 1
A __toString() 0 4 1
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\IR\SymbolTable;
11
12
use Railt\SDL\IR\Type\TypeInterface;
13
14
/**
15
 * Class Value
16
 */
17
class Value implements ValueInterface
18
{
19
    /**
20
     * @var TypeInterface|null
21
     */
22
    private $type;
23
24
    /**
25
     * @var int|string|null|float|bool|PrimitiveInterface
26
     */
27
    private $value;
28
29
    /**
30
     * Value constructor.
31
     * @param TypeInterface $type
32
     * @param mixed $value
33
     */
34
    public function __construct($value, TypeInterface $type)
35
    {
36
        \assert(\is_scalar($value) || $value instanceof PrimitiveInterface);
37
38
        $this->type = $type;
39
        $this->value = $value;
40
    }
41
42
    /**
43
     * @return int|string|null|float|bool|PrimitiveInterface
44
     */
45
    public function getValue()
46
    {
47
        return $this->value;
48
    }
49
50
    /**
51
     * @return TypeInterface
52
     */
53
    public function getType(): TypeInterface
54
    {
55
        return $this->type;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function __toString(): string
62
    {
63
        return \sprintf('<%s:%s>', $this->type, $this->value);
64
    }
65
}
66