Test Failed
Push — master ( ecd78b...d05c81 )
by Kirill
02:43
created

StringValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toString() 0 12 1
A getValue() 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\Frontend\IR\Value;
11
12
/**
13
 * Class StringValue
14
 */
15
class StringValue extends AbstractValue
16
{
17
    /**
18
     * ConstantValue constructor.
19
     * @param string $value
20
     * @param int $offset
21
     */
22
    public function __construct(string $value, int $offset = 0)
23
    {
24
        parent::__construct($value, $offset);
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function toString(): string
31
    {
32
        $result = \addcslashes($this->getValue(), '"\\');
33
34
        $result = \str_replace(
35
            ["\b", "\f", "\n", "\r", "\t"],
36
            ['\u0092', '\u0012', '\u0010', '\u0013', '\u0009'],
37
            $result
38
        );
39
40
        return \sprintf('"%s"', $result);
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getValue(): string
47
    {
48
        return parent::getValue();
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function __toString(): string
55
    {
56
        return '(string)' . parent::__toString();
57
    }
58
}
59