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.
Completed
Push — master ( 0097ae...d93d91 )
by Андрей
02:02
created

Step::getStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @link    https://github.com/old-town/workflow-doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Spi\Doctrine\Entity;
7
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\ORM\Mapping as ORM;
10
use DateTime;
11
use Traversable;
12
13
14
/**
15
 * Class CurrentStep
16
 *
17
 * @package OldTown\Workflow\Spi\Doctrine\Entity
18
 *
19
 * @ORM\Entity(repositoryClass="\OldTown\Workflow\Spi\Doctrine\EntityRepository\StepRepository")
20
 * @ORM\Table(
21
 *     name="wf_step",
22
 *     indexes={
23
 *         @ORM\Index(name="owner", columns={"owner"}),
24
 *         @ORM\Index(name="caller", columns={"caller"}),
25
 *         @ORM\Index(name="type", columns={"type"}),
26
 *     }
27
 * )
28
 */
29
class Step implements StepInterface
30
{
31
    /**
32
     * @ORM\Id()
33
     * @ORM\Column(name="id", type="integer")
34
     * @ORM\GeneratedValue(strategy="IDENTITY")
35
     *
36
     * @var integer
37
     */
38
    protected $id;
39
40
    /**
41
     * @ORM\Column(name="action_Id", type="integer", nullable=true)
42
     *
43
     * @var integer
44
     */
45
    protected $actionId;
46
47
    /**
48
     * @ORM\Column(name="caller", type="string", length=35, nullable=true)
49
     *
50
     * @var string
51
     */
52
    protected $caller;
53
54
    /**
55
     * @ORM\Column(name="finish_date", type="datetime", nullable=true)
56
     *
57
     * @var DateTime
58
     */
59
    protected $finishDate;
60
61
    /**
62
     * @ORM\Column(name="start_date", type="datetime")
63
     *
64
     * @var DateTime
65
     */
66
    protected $startDate;
67
68
    /**
69
     * @ORM\Column(name="due_date", type="datetime", nullable=true)
70
     *
71
     * @var DateTime
72
     */
73
    protected $dueDate;
74
75
    /**
76
     * @ORM\Column(name="owner", type="string", length=35, nullable=true)
77
     *
78
     * @var string
79
     */
80
    protected $owner;
81
82
    /**
83
     * @ORM\Column(name="status", type="string", length=40, nullable=true)
84
     *
85
     * @var string
86
     */
87
    protected $status;
88
89
    /**
90
     * @ORM\Column(name="step_id", type="integer")
91
     *
92
     * @var integer
93
     */
94
    protected $stepId;
95
96
    /**
97
     *
98
     * @ORM\ManyToMany(targetEntity="Step")
99
     * @ORM\JoinTable(
100
     *     name="wf_previous_step",
101
     *     joinColumns={@ORM\JoinColumn(name="current_step_id", referencedColumnName="id")},
102
     *     inverseJoinColumns={@ORM\JoinColumn(name="previous_step_id", referencedColumnName="id")}
103
     * )
104
     *
105
     * @var ArrayCollection|StepInterface[]
106
     */
107
    protected $previousSteps;
108
109
    /**
110
     * Определяет тип шага
111
     *
112
     * @ORM\Column(name="type", type="string", length=15, nullable=false)
113
     *
114
     * @var string
115
     */
116
    protected $type;
117
118
    /**
119
     * @ORM\ManyToOne(targetEntity="AbstractEntry", inversedBy="steps")
120
     * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
121
     *
122
     * @var EntryInterface
123
     */
124
    protected $entry;
125
126
    /**
127
     * Разрешенные типы шагов
128
     *
129
     * @var array
130
     */
131
    protected $accessType = [
132
        self::CURRENT_STEP => self::CURRENT_STEP,
133
        self::HISTORY_STEP => self::HISTORY_STEP,
134
    ];
135
136
    /**
137
     *
138
     */
139
    public function __construct()
140
    {
141
        $this->previousSteps =  new ArrayCollection();
142
    }
143
144
145
    /**
146
     * @return string
147
     */
148
    public function getId()
149
    {
150
        return $this->id;
151
    }
152
153
    /**
154
     * @param string $id
155
     *
156
     * @return $this
157
     */
158
    public function setId($id)
159
    {
160
        $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type integer, but $id is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return integer
167
     */
168
    public function getActionId()
169
    {
170
        return $this->actionId;
171
    }
172
173
    /**
174
     * @param integer $actionId
175
     *
176
     * @return $this
177
     */
178
    public function setActionId($actionId = null)
179
    {
180
        $this->actionId = null !== $actionId ? (integer)$actionId : $actionId;
181
182
        return $this;
183
    }
184
185
    /**
186
     * @return string
187
     */
188
    public function getCaller()
189
    {
190
        return $this->caller;
191
    }
192
193
    /**
194
     * @param string $caller
195
     *
196
     * @return $this
197
     */
198
    public function setCaller($caller = null)
199
    {
200
        $this->caller = null !== $caller ? (string)$caller : $caller;
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return DateTime
207
     */
208
    public function getFinishDate()
209
    {
210
        return $this->finishDate;
211
    }
212
213
    /**
214
     * @param DateTime $finishDate
215
     *
216
     * @return $this
217
     */
218
    public function setFinishDate(DateTime $finishDate = null)
219
    {
220
        $this->finishDate = $finishDate;
221
222
        return $this;
223
    }
224
225
    /**
226
     * @return DateTime
227
     */
228
    public function getStartDate()
229
    {
230
        return $this->startDate;
231
    }
232
233
    /**
234
     * @param DateTime $startDate
235
     *
236
     * @return $this
237
     */
238
    public function setStartDate(DateTime $startDate)
239
    {
240
        $this->startDate = $startDate;
241
242
        return $this;
243
    }
244
245
    /**
246
     * @return DateTime
247
     */
248
    public function getDueDate()
249
    {
250
        return $this->dueDate;
251
    }
252
253
    /**
254
     * @param DateTime $dueDate
255
     *
256
     * @return $this
257
     */
258
    public function setDueDate(DateTime $dueDate = null)
259
    {
260
        $this->dueDate = $dueDate;
261
262
        return $this;
263
    }
264
265
    /**
266
     * @return string
267
     */
268
    public function getOwner()
269
    {
270
        return $this->owner;
271
    }
272
273
    /**
274
     * @param string $owner
275
     *
276
     * @return $this
277
     */
278
    public function setOwner($owner)
279
    {
280
        $this->owner = null !== $owner ? (string)$owner : $owner;
281
282
        return $this;
283
    }
284
285
    /**
286
     * @return string
287
     */
288
    public function getStatus()
289
    {
290
        return $this->status;
291
    }
292
293
    /**
294
     * @param string $status
295
     *
296
     * @return $this
297
     */
298
    public function setStatus($status)
299
    {
300
        $this->status = (string)$status;
301
302
        return $this;
303
    }
304
305
    /**
306
     * @return string
307
     */
308
    public function getStepId()
309
    {
310
        return $this->stepId;
311
    }
312
313
    /**
314
     * @param string $stepId
315
     *
316
     * @return $this
317
     */
318
    public function setStepId($stepId)
319
    {
320
        $this->stepId = (string)$stepId;
0 ignored issues
show
Documentation Bug introduced by
The property $stepId was declared of type integer, but (string) $stepId is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
321
322
        return $this;
323
    }
324
325
    /**
326
     * Возвращает id процесса
327
     *
328
     * @return integer
329
     */
330
    public function getEntryId()
331
    {
332
        return $this->getEntry()->getId();
333
    }
334
335
    /**
336
     * Возвращает id предыдущхи шагов
337
     *
338
     */
339
    public function getPreviousStepIds()
340
    {
341
        $previousStepIds = [];
342
        $previousSteps = $this->getPreviousSteps();
343
344
        foreach ($previousSteps as $previousStep) {
345
            $id = $previousStep->getId();
346
            $previousStepIds[$id] = $id;
347
        }
348
349
        return $previousStepIds;
350
    }
351
352
    /**
353
     * @return ArrayCollection|StepInterface[]
354
     */
355
    public function getPreviousSteps()
356
    {
357
        return $this->previousSteps;
358
    }
359
360
    /**
361
     * @param ArrayCollection|StepInterface[] $previousSteps
362
     *
363
     * @return $this
364
     *
365
     * @throws Exception\InvalidArgumentException
366
     */
367
    public function setPreviousSteps($previousSteps)
368
    {
369
        if (!is_array($previousSteps) && !$previousSteps instanceof Traversable) {
370
            $errMsg = 'previousSteps is not array';
371
            throw new Exception\InvalidArgumentException($errMsg);
372
        }
373
374
        foreach ($previousSteps as $previousStep) {
375
            if (!$previousStep instanceof StepInterface) {
376
                $errMsg = sprintf('step not implement %s', StepInterface::class);
377
                throw new Exception\InvalidArgumentException($errMsg);
378
            }
379
            if (!$this->previousSteps->contains($previousStep)) {
380
                $this->previousSteps->add($previousStep);
381
            }
382
        }
383
        return $this;
384
    }
385
386
    /**
387
     * Возвращает тип шага
388
     *
389
     * @return string
390
     */
391
    public function getType()
392
    {
393
        return $this->type;
394
    }
395
396
    /**
397
     * Устанавливает тип шага
398
     *
399
     * @param string $type
400
     *
401
     * @return $this
402
     *
403
     * @throws Exception\InvalidArgumentException
404
     */
405
    public function setType($type)
406
    {
407
        if (!array_key_exists($type, $this->accessType)) {
408
            $errMsg = sprintf('Invalid step type %s', $type);
409
            throw new Exception\InvalidArgumentException($errMsg);
410
        }
411
        $this->type = $type;
412
413
        return $this;
414
    }
415
416
    /**
417
     * @return EntryInterface
418
     */
419
    public function getEntry()
420
    {
421
        return $this->entry;
422
    }
423
424
    /**
425
     * @param EntryInterface $entry
426
     *
427
     * @return $this
428
     */
429
    public function setEntry(EntryInterface $entry)
430
    {
431
        $this->entry = $entry;
432
433
        if (!$entry->getSteps()->contains($this)) {
434
            $entry->getSteps()->add($this);
435
        }
436
437
        return $this;
438
    }
439
}
440