1 | <?php |
||
9 | class Candidate |
||
10 | { |
||
11 | const STATUS_QUEUED = 'QUEUED'; |
||
12 | const STATUS_PENDING = 'PENDING'; |
||
13 | const STATUS_ALREADY_DEPLOYED = 'ALREADY_DEPLOYED'; |
||
14 | const STATUS_HAS_SYNTAX_ERROR = 'HAS_SYNTAX_ERROR'; |
||
15 | |||
16 | const FILES_MASK = '/^\d{3,}\_.*\.sql$/'; |
||
17 | |||
18 | private static $supportedStates = [self::STATUS_PENDING, self::STATUS_QUEUED, self::STATUS_ALREADY_DEPLOYED, self::STATUS_HAS_SYNTAX_ERROR]; |
||
19 | |||
20 | /** @var string */ |
||
21 | private $name; |
||
22 | |||
23 | /** @var string */ |
||
24 | private $content; |
||
25 | |||
26 | /** @var string */ |
||
27 | private $status; |
||
28 | |||
29 | /** @var integer */ |
||
30 | private $index; |
||
31 | |||
32 | /** @var int */ |
||
33 | private $number; |
||
34 | |||
35 | /** @var boolean */ |
||
36 | private $ignored; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @param string $name |
||
41 | * @param string $content |
||
42 | * @throws Exception |
||
43 | */ |
||
44 | 5 | public function __construct($name, $content) |
|
57 | |||
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | 3 | public function getName() |
|
66 | |||
67 | |||
68 | /** |
||
69 | * @return void |
||
70 | */ |
||
71 | 1 | public function markAsQueued() |
|
75 | |||
76 | |||
77 | |||
78 | /** |
||
79 | * @param string $causeStatus |
||
80 | */ |
||
81 | 1 | public function markAsIgnored($causeStatus) |
|
87 | |||
88 | |||
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | public function getStatus() |
||
97 | |||
98 | |||
99 | |||
100 | /** |
||
101 | * @param int $index |
||
102 | */ |
||
103 | public function setIndex($index) |
||
107 | |||
108 | |||
109 | |||
110 | /** |
||
111 | * @return string |
||
112 | */ |
||
113 | 3 | public function getContent() |
|
117 | |||
118 | |||
119 | |||
120 | /** |
||
121 | * @return int |
||
122 | */ |
||
123 | public function getIndex() |
||
127 | |||
128 | |||
129 | |||
130 | /** |
||
131 | * @return int |
||
132 | */ |
||
133 | 1 | public function getNumber() |
|
137 | |||
138 | |||
139 | /** |
||
140 | * @return bool |
||
141 | */ |
||
142 | 3 | public function isIgnored() |
|
146 | |||
147 | /** |
||
148 | * @return bool |
||
149 | */ |
||
150 | 1 | public function isQueued() |
|
154 | |||
155 | /** |
||
156 | * @return bool |
||
157 | */ |
||
158 | 1 | public function isPending() |
|
162 | |||
163 | /** |
||
164 | * @return bool |
||
165 | */ |
||
166 | 1 | public function isAlreadyDeployed() |
|
170 | |||
171 | /** |
||
172 | * @param string $newState |
||
173 | */ |
||
174 | 2 | private function changeState($newState) |
|
182 | } |
||
183 |