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.

SimpleStep   A
last analyzed

Complexity

Total Complexity 32

Size/Duplication

Total Lines 390
Duplicated Lines 10.77 %

Coupling/Cohesion

Components 4
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 32
c 2
b 0
f 0
lcom 4
cbo 1
dl 42
loc 390
ccs 97
cts 97
cp 1
rs 9.6

26 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A setActionId() 12 12 3
A getActionId() 0 4 1
A setCaller() 0 6 2
A getCaller() 0 4 1
A setDueDate() 0 6 1
A getDueDate() 0 4 1
A setEntryId() 11 11 2
A getEntryId() 0 4 1
A setFinishDate() 0 5 1
A getFinishDate() 0 4 1
A setId() 9 9 2
A getId() 0 4 1
A setOwner() 0 5 1
A getOwner() 0 4 1
A setPreviousStepIds() 0 6 1
A getPreviousStepIds() 0 4 1
A setStartDate() 0 6 1
A getStartDate() 0 4 1
A setStatus() 0 6 1
A getStatus() 0 4 1
A setStepId() 10 10 2
A getStepId() 0 4 1
A __toString() 0 9 1
A serialize() 0 5 1
A unserialize() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @link https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Spi;
7
8
use OldTown\Workflow\Exception\ArgumentNotNumericException;
9
use Serializable;
10
use \DateTime;
11
12
13
/**
14
 * Interface WorkflowContextInterface
15
 *
16
 * @package OldTown\Workflow\Spi\StepInterface
17
 */
18
class SimpleStep implements StepInterface, Serializable
19
{
20
    /**
21
     *
22
     * @var DateTime|null
23
     */
24
    private $dueDate;
25
26
    /**
27
     *
28
     * @var DateTime|null
29
     */
30
    private $finishDate;
31
32
    /**
33
     *
34
     * @var DateTime
35
     */
36
    private $startDate;
37
38
    /**
39
     * @var string|null
40
     */
41
    private $caller;
42
43
    /**
44
     * @var string
45
     */
46
    private $owner;
47
48
    /**
49
     * @var string
50
     */
51
    private $status;
52
53
    /**
54
     * @var array
55
     */
56
    private $previousStepIds = [];
57
58
    /**
59
     * @var integer
60
     */
61
    private $actionId;
62
63
    /**
64
     * @var integer
65
     */
66
    private $stepId;
67
68
    /**
69
     * @var integer
70
     */
71
    private $entryId;
72
73
    /**
74
     * @var integer
75
     */
76
    private $id;
77
78 46
    public function __construct($id, $entryId, $stepId, $actionId, $owner, DateTime $startDate, DateTime $dueDate = null, DateTime $finishDate = null, $status, array $previousStepIds = [], $caller)
79
    {
80 46
        $this->setId($id);
81 46
        $this->setEntryId($entryId);
82 46
        $this->setStepId($stepId);
83 46
        $this->setActionId($actionId);
84 46
        $this->setOwner($owner);
85 46
        $this->setStartDate($startDate);
86 46
        $this->setFinishDate($finishDate);
87 46
        $this->setDueDate($dueDate);
88 46
        $this->setStatus($status);
89 46
        $this->setPreviousStepIds($previousStepIds);
90 46
        $this->setCaller($caller);
91 46
    }
92
93
    //~ Methods ////////////////////////////////////////////////////////////////
94
95
    /**
96
     * Устанавливает id действия
97
     *
98
     * @param integer $actionId
99
     * @return $this
100
     *
101
     * @throws ArgumentNotNumericException
102
     */
103 46 View Code Duplication
    public function setActionId($actionId)
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...
104
    {
105 46
        if ($actionId !== null) {
106 46
            if (!is_numeric($actionId)) {
107 1
                $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $actionId);
108 1
                throw new ArgumentNotNumericException($errMsg);
109
            }
110 46
            $this->actionId = (integer)$actionId;
111 46
        }
112
113 46
        return $this;
114
    }
115
116
    /**
117
     * Возвращает id действия
118
     *
119
     * @return integer
120
     */
121 4
    public function getActionId()
122
    {
123 4
        return $this->actionId;
124
    }
125
126
    /**
127
     * Устанавливает имя того кто вызвал действие приведшее к переходу на данный шаг
128
     *
129
     * @param $caller|null
130
     * @return $this
131
     */
132 46
    public function setCaller($caller = null)
133
    {
134 46
        $this->caller = (null !== $caller) ? (string)$caller : null;
135
136 46
        return $this;
137
    }
138
139
    /**
140
     * Возвращает имя того кто вызвал действие приведшее к переходу на данный шаг
141
     *
142
     * @return string|null
143
     */
144 2
    public function getCaller()
145
    {
146 2
        return $this->caller;
147
    }
148
149
    /**
150
     * Устанавливает период
151
     *
152
     * @param DateTime $dueDate
153
     * @return $this
154
     */
155 46
    public function setDueDate(DateTime $dueDate = null)
156
    {
157 46
        $this->dueDate = $dueDate;
158
159 46
        return $this;
160
    }
161
162
    /**
163
     * Возвращает период
164
     *
165
     * @return DateTime|null
166
     */
167 2
    public function getDueDate()
168
    {
169 2
        return $this->dueDate;
170
    }
171
172
    /**
173
     * Устанавливает id экземпляра workflow
174
     *
175
     * @param integer $entryId
176
     * @return $this
177
     *
178
     * @throws ArgumentNotNumericException
179
     */
180 46 View Code Duplication
    public function setEntryId($entryId)
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...
181
    {
182 46
        if (!is_numeric($entryId)) {
183 1
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $entryId);
184 1
            throw new ArgumentNotNumericException($errMsg);
185
        }
186
187 46
        $this->entryId = (integer)$entryId;
188
189 46
        return $this;
190
    }
191
192
    /**
193
     * Возвращает id экземпляра workflow
194
     *
195
     * @return int
196
     */
197 7
    public function getEntryId()
198
    {
199 7
        return $this->entryId;
200
    }
201
202
    /**
203
     * Устанавливает дату окончания когда сущность прибывала в данном состояние
204
     *
205
     * @param DateTime $finishDate
206
     * @return $this
207
     */
208 46
    public function setFinishDate(DateTime $finishDate = null)
209
    {
210 46
        $this->finishDate = $finishDate;
211 46
        return $this;
212
    }
213
214
    /**
215
     * Возвращает дату окончания когда сущность прибывала в данном состояние
216
     *
217
     * @return DateTime|null
218
     */
219 2
    public function getFinishDate()
220
    {
221 2
        return $this->finishDate;
222
    }
223
224
    /**
225
     * Устанавливает id шага
226
     *
227
     * @param integer $id
228
     * @return $this
229
     *
230
     * @throws ArgumentNotNumericException
231
     */
232 46 View Code Duplication
    public function setId($id)
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...
233
    {
234 46
        if (!is_numeric($id)) {
235 1
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $id);
236 1
            throw new ArgumentNotNumericException($errMsg);
237
        }
238 46
        $this->id = (integer)$id;
239 46
        return $this;
240
    }
241
242
    /**
243
     * Возвращает id шага
244
     *
245
     * @return int
246
     */
247 8
    public function getId()
248
    {
249 8
        return $this->id;
250
    }
251
252
    /**
253
     * Устанавливает имя того кто является владельцем данного шага
254
     *
255
     * @param string $owner
256
     * @return $this
257
     */
258 46
    public function setOwner($owner)
259
    {
260 46
        $this->owner = (string)$owner;
261 46
        return $this;
262
    }
263
264
    /**
265
     * Возвращает имя того кто является владельцем данного шага
266
     *
267
     * @return string
268
     */
269 3
    public function getOwner()
270
    {
271 3
        return $this->owner;
272
    }
273
274
    /**
275
     * Устанавливает id предыдущих шагов
276
     *
277
     * @param array $previousStepIds
278
     * @return $this
279
     */
280 46
    public function setPreviousStepIds(array $previousStepIds = [])
281
    {
282 46
        $this->previousStepIds = $previousStepIds;
283
284 46
        return $this;
285
    }
286
287
    /**
288
     * Возвращает id предыдущих шагов
289
     *
290
     * @return array
291
     */
292 1
    public function getPreviousStepIds()
293
    {
294 1
        return $this->previousStepIds;
295
    }
296
297
    /**
298
     * Устанавливает дату, когда workflow перешло в данный шаг
299
     *
300
     * @param DateTime $startDate
301
     * @return $this
302
     */
303 46
    public function setStartDate(DateTime $startDate)
304
    {
305 46
        $this->startDate = $startDate;
306
307 46
        return $this;
308
    }
309
310
    /**
311
     * Возвращает дату, когда workflow перешло в данный шаг
312
     *
313
     * @return DateTime
314
     */
315 2
    public function getStartDate()
316
    {
317 2
        return $this->startDate;
318
    }
319
320
    /**
321
     * Устанавливает статус в котором находится шаг
322
     *
323
     * @param $status
324
     * @return $this
325
     */
326 46
    public function setStatus($status)
327
    {
328 46
        $this->status = (string)$status;
329
330 46
        return $this;
331
    }
332
333
    /**
334
     * Возвращает статус в котором находится шаг
335
     *
336
     * @return string
337
     */
338 3
    public function getStatus()
339
    {
340 3
        return $this->status;
341
    }
342
343
    /**
344
     * Устанавливает id шгага
345
     *
346
     * @param integer $stepId
347
     * @return $this
348
     *
349
     * @throws ArgumentNotNumericException
350
     */
351 46 View Code Duplication
    public function setStepId($stepId)
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...
352
    {
353 46
        if (!is_numeric($stepId)) {
354 1
            $errMsg = sprintf('Аргумент должен быть числом. Актуальное значение %s', $stepId);
355 1
            throw new ArgumentNotNumericException($errMsg);
356
        }
357 46
        $this->stepId = (integer)$stepId;
358
359 46
        return $this;
360
    }
361
362
    /**
363
     * Возвращает id шгага
364
     *
365
     * @return int
366
     */
367 19
    public function getStepId()
368
    {
369 19
        return $this->stepId;
370
    }
371
372
    /**
373
     * Отображение состояние шага в текстовом виде
374
     *
375
     * @return string
376
     */
377 1
    public function __toString()
378
    {
379 1
        $r = sprintf('SimpleStep@ %s[owner=%s, actionId=%s, status=%s]',
380 1
        $this->getStepId(),
381 1
        $this->getOwner(),
382 1
        $this->getActionId(),
383 1
        $this->getStatus());
384 1
        return $r;
385
    }
386
387
    /**
388
     * @link http://php.net/manual/en/serializable.serialize.php
389
     * @return string
390
     */
391 1
    public function serialize()
392
    {
393 1
        $errMsg = sprintf('Метод %s класса %s требуется реализовать', __METHOD__, __CLASS__);
394 1
        trigger_error($errMsg, E_USER_ERROR);
395 1
    }
396
397
    /**
398
     * @link http://php.net/manual/en/serializable.unserialize.php
399
     * @param string $serialized
400
     * @return void
401
     */
402 1
    public function unserialize($serialized)
403
    {
404 1
        $errMsg = sprintf('Метод %s класса %s требуется реализовать', __METHOD__, __CLASS__);
405 1
        trigger_error($errMsg, E_USER_ERROR);
406 1
    }
407
}
408