Operator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Pluswerk\TypoScriptAutoFixer\Fixer\NestingConsistency;
5
6
final class Operator
7
{
8
    private const EQUAL = '=';
9
    private const REFERENCE =  '=<';
10
    private const COPY = '<';
11
    private const DELETE = '>';
12
    private const MODIFICATION = ':=';
13
    public const MULTI_LINE = '()';
14
15
    /**
16
     * @var string
17
     */
18
    private $operator;
19
20
    /**
21
     * @return Operator
22
     */
23
    public static function createEqual(): Operator
24
    {
25
        return new self(self::EQUAL);
26
    }
27
28
    /**
29
     * @return Operator
30
     */
31
    public static function createReference(): Operator
32
    {
33
        return new self(self::REFERENCE);
34
    }
35
36
    /**
37
     * @return Operator
38
     */
39
    public static function createCopy(): Operator
40
    {
41
        return new self(self::COPY);
42
    }
43
44
    /**
45
     * @return Operator
46
     */
47
    public static function createDelete(): Operator
48
    {
49
        return new self(self::DELETE);
50
    }
51
52
    /**
53
     * @return Operator
54
     */
55
    public static function createModification(): Operator
56
    {
57
        return new self(self::MODIFICATION);
58
    }
59
60
    /**
61
     * @return Operator
62
     */
63
    public static function createMultiLine(): Operator
64
    {
65
        return new self(self::MULTI_LINE);
66
    }
67
68
    /**
69
     * Operator constructor.
70
     *
71
     * @param string $operatorString
72
     */
73
    private function __construct(string $operatorString)
74
    {
75
        $this->operator = $operatorString;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81
    public function isMultiLine(): bool
82
    {
83
        return $this->operator === self::MULTI_LINE;
84
    }
85
86
    /**
87
     * @return bool
88
     */
89
    public function isCopy(): bool
90
    {
91
        return $this->operator === self::COPY;
92
    }
93
94
    /**
95
     * @return bool
96
     */
97
    public function isReference(): bool
98
    {
99
        return $this->operator === self::REFERENCE;
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function __toString()
106
    {
107
        return $this->operator;
108
    }
109
}
110