Passed
Push — master ( 1e50c2...24b8dd )
by noitran
01:21
created

AbstractExpr::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Noitran\RQL\Expressions;
4
5
use Noitran\RQL\Contracts\Expression\ExprInterface;
6
7
/**
8
 * Class AbstractExpr
9
 */
10
abstract class AbstractExpr implements ExprInterface
11
{
12
    /**
13
     * @var string|null
14
     */
15
    protected $relation;
16
17
    /**
18
     * @var string
19
     */
20
    protected $column;
21
22
    /**
23
     * @var mixed
24
     */
25
    protected $value;
26
27
    /**
28
     * @var string
29
     */
30
    protected $expression;
31
32
    /**
33
     * @var string
34
     */
35
    protected $operator;
36
37
    /**
38
     * AbstractExpr constructor.
39
     *
40
     * @param string|null $relation
41
     * @param string $column
42
     * @param mixed $value
43
     */
44
    public function __construct(?string $relation, string $column, $value)
45
    {
46
        $this->relation = $relation;
47
        $this->column = $column;
48
        $this->value = $value;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function getRelation(): ?string
55
    {
56
        return $this->relation;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function getColumn(): string
63
    {
64
        return $this->column;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function getValue()
71
    {
72
        return $this->value;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78
    public function setExpression(string $expression = null): self
79
    {
80
        $this->expression = $expression;
81
82
        return $this;
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function getExpression(): string
89
    {
90
        return $this->expression;
91
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96
    public function setOperator(string $operator = null): self
97
    {
98
        $this->operator = $operator;
99
100
        return $this;
101
    }
102
103
    /**
104
     * @inheritdoc
105
     */
106
    public function getOperator(): string
107
    {
108
        return $this->operator;
109
    }
110
111
    /**
112
     * @param $delimiter
113
     * @param $value
114
     *
115
     * @return array
116
     */
117
    protected function valueToArray($delimiter, $value): array
118
    {
119
        return explode($delimiter, $value);
120
    }
121
}
122