1 | <?php |
||
13 | final class State |
||
14 | { |
||
15 | /** |
||
16 | * Migration statues. |
||
17 | */ |
||
18 | const STATUS_UNDEFINED = -1; |
||
19 | const STATUS_PENDING = 0; |
||
20 | const STATUS_EXECUTED = 1; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $name = ''; |
||
26 | |||
27 | /** |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $status = self::STATUS_PENDING; |
||
31 | |||
32 | /** |
||
33 | * @var \DateTime |
||
34 | */ |
||
35 | private $timeCreated = null; |
||
36 | |||
37 | /** |
||
38 | * @var \DateTime|null |
||
39 | */ |
||
40 | private $timeExecuted = null; |
||
41 | |||
42 | /** |
||
43 | * @param string $name |
||
44 | * @param \DateTime $timeCreated |
||
45 | * @param int $status |
||
46 | * @param \DateTime $timeExecuted |
||
47 | */ |
||
48 | public function __construct( |
||
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getName(): string |
||
67 | |||
68 | /** |
||
69 | * Migration status. |
||
70 | * |
||
71 | * @return int |
||
72 | */ |
||
73 | public function getStatus(): int |
||
77 | |||
78 | /** |
||
79 | * Get migration creation time. |
||
80 | * |
||
81 | * @return \DateTime |
||
82 | */ |
||
83 | public function getTimeCreated(): \DateTime |
||
87 | |||
88 | /** |
||
89 | * Get migration execution time if any. |
||
90 | * |
||
91 | * @return \DateTime|null |
||
92 | */ |
||
93 | public function getTimeExecuted() |
||
97 | |||
98 | /** |
||
99 | * @param int $status |
||
100 | * @param \DateTime|null $timeExecuted |
||
101 | * |
||
102 | * @return State |
||
103 | */ |
||
104 | public function withStatus(int $status, \DateTime $timeExecuted = null): State |
||
112 | } |
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.