GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FieldExpression::getField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Query;
7
8
use OldTown\Workflow\Exception\ArgumentNotNumericException;
9
use OldTown\Workflow\Exception\InvalidArgumentException;
10
11
/**
12
 * Class FieldExpression
13
 * @package OldTown\Workflow\Query
14
 */
15
class FieldExpression extends AbstractExpression
16
{
17
    /**
18
     * Константа для оператора сравнения
19
     *
20
     * @var integer
21
     */
22
    const EQUALS = 1;
23
24
    /**
25
     * Константа для оператора сравнения
26
     *
27
     * @var integer
28
     */
29
    const LT = 2;
30
31
    /**
32
     * Константа для оператора сравнения
33
     *
34
     * @var integer
35
     */
36
    const GT = 3;
37
38
    /**
39
     * Константа для оператора сравнения
40
     *
41
     * @var integer
42
     */
43
    const NOT_EQUALS = 5;
44
45
    // fields
46
47
    /**
48
     * Константа для поля "владелец" в workflow
49
     *
50
     * @var integer
51
     */
52
    const OWNER = 1;
53
54
    /**
55
     * Константа для даты создания
56
     *
57
     * @var integer
58
     */
59
    const START_DATE = 2;
60
61
    /**
62
     * Константа для даты окончания
63
     *
64
     * @var integer
65
     */
66
    const FINISH_DATE = 3;
67
68
    /**
69
     * Константа для действия
70
     *
71
     * @var integer
72
     */
73
    const ACTION = 4;
74
75
    /**
76
     * Константа для шага
77
     *
78
     * @var integer
79
     */
80
    const STEP = 5;
81
82
    /**
83
     * Константа опредяющая того кто вызвал переход в соотвтетсвтующее состояние
84
     *
85
     * @var integer
86
     */
87
    const CALLER = 6;
88
89
    /**
90
     * Константа определяющее поле со статусом
91
     *
92
     * @var integer
93
     */
94
    const STATUS = 7;
95
96
    /**
97
     * Константа для поля - имя
98
     *
99
     * @var integer
100
     */
101
    const NAME = 8;
102
103
    /**
104
     * Константа для поля состояния
105
     *
106
     * @var integer
107
     */
108
    const STATE = 9;
109
110
    /**
111
     * Константа для интервала
112
     *
113
     * @var integer
114
     */
115
    const DUE_DATE = 10;
116
117
    // field context
118
119
    /**
120
     * Константа для поиса по истории шагов
121
     *
122
     * @var integer
123
     */
124
    const HISTORY_STEPS = 1;
125
126
    /**
127
     * Константа для поиска в текущих шагах
128
     *
129
     * @var integer
130
     */
131
    const CURRENT_STEPS = 2;
132
133
    /**
134
     * Константа для поиска по экземпляру workflow
135
     *
136
     * @var integer
137
     */
138
    const ENTRY = 3;
139
140
    /**
141
     * @var mixed
142
     */
143
    private $value;
144
145
    /**
146
     * @var integer
147
     */
148
    private $context;
149
150
    /**
151
     * @var integer
152
     */
153
    private $field;
154
155
    /**
156
     * @var integer
157
     */
158
    private $operator;
159
160
    /**
161
     * @param integer $field
162
     * @param integer $context
163
     * @param integer $operator
164
     * @param mixed $value
165
     * @param bool $negate
166
     *
167
     * @throws ArgumentNotNumericException
168
     * @throws InvalidArgumentException
169
     */
170 13
    public function __construct($field, $context, $operator, $value, $negate = false)
171
    {
172 13
        $this->setValue($value);
173 13
        $this->setContext($context);
174 13
        $this->setField($field);
175 13
        $this->setOperator($operator);
176 13
        $this->negate = (boolean)$negate;
177 13
    }
178
179
    /**
180
     * Возвращает значение
181
     *
182
     * @return mixed
183
     */
184 12
    public function getValue()
185
    {
186 12
        return $this->value;
187
    }
188
189
    /**
190
     * Устанавливает значение
191
     *
192
     * @param mixed $value
193
     * @return $this
194
     * @throws InvalidArgumentException
195
     */
196 13
    public function setValue($value)
197
    {
198 13
        $this->value = $value;
199
200 13
        return $this;
201
    }
202
203
    /**
204
     * Возвращает контекст
205
     *
206
     * @return int
207
     */
208 12
    public function getContext()
209
    {
210 12
        return $this->context;
211
    }
212
213
    /**
214
     * Устанавливает контекст
215
     *
216
     * @param int $context
217
     * @return $this
218
     * @throws ArgumentNotNumericException
219
     */
220 13 View Code Duplication
    public function setContext($context)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
221
    {
222 13
        if (!is_numeric($context)) {
223
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $context);
224
            throw new ArgumentNotNumericException($errMsg);
225
        }
226
227 13
        $this->context = (integer)$context;
228
229 13
        return $this;
230
    }
231
232
    /**
233
     * Возвращает поле
234
     *
235
     * @return int
236
     */
237 12
    public function getField()
238
    {
239 12
        return $this->field;
240
    }
241
242
    /**
243
     * Устанавливает поле
244
     *
245
     * @param int $field
246
     * @return $this
247
     * @throws ArgumentNotNumericException
248
     */
249 13 View Code Duplication
    public function setField($field)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
250
    {
251 13
        if (!is_numeric($field)) {
252
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $field);
253
            throw new ArgumentNotNumericException($errMsg);
254
        }
255
256 13
        $this->field = (integer)$field;
257
258 13
        return $this;
259
    }
260
261
    /**
262
     * Возвращает оператор
263
     *
264
     * @return int
265
     */
266 12
    public function getOperator()
267
    {
268 12
        return $this->operator;
269
    }
270
271
    /**
272
     * Устанавливает оператор
273
     *
274
     * @param int $operator
275
     * @return $this
276
     * @throws ArgumentNotNumericException
277
     */
278 13 View Code Duplication
    public function setOperator($operator)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
279
    {
280 13
        if (!is_numeric($operator)) {
281
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $operator);
282
            throw new ArgumentNotNumericException($errMsg);
283
        }
284
285 13
        $this->operator = (integer)$operator;
286
287 13
        return $this;
288
    }
289
290
291
292
    /**
293
     * Флаг определяющий есть ли вложенные свойства
294
     *
295
     * @return boolean
296
     */
297 12
    public function isNested()
298
    {
299 12
        return false;
300
    }
301
}
302