1 | <?php |
||
8 | class QueuedTask implements QueuedTaskInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var int |
||
12 | */ |
||
13 | protected $id; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $pid; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $name; |
||
24 | |||
25 | /** |
||
26 | * @var \DateTime |
||
27 | */ |
||
28 | protected $created; |
||
29 | |||
30 | /** |
||
31 | * @var \DateTime |
||
32 | */ |
||
33 | protected $updated; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $params = []; |
||
39 | |||
40 | /** |
||
41 | * @var ScheduleInterface |
||
42 | */ |
||
43 | protected $schedule; |
||
44 | |||
45 | /** |
||
46 | * @var \DateTime |
||
47 | */ |
||
48 | protected $executeAt; |
||
49 | |||
50 | /** |
||
51 | * @var \DateTime |
||
52 | */ |
||
53 | protected $started; |
||
54 | |||
55 | /** |
||
56 | * @var \DateTime |
||
57 | */ |
||
58 | protected $finished; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $result; |
||
64 | |||
65 | /** |
||
66 | * @var int |
||
67 | */ |
||
68 | protected $progress; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $progressInfo; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | protected $status = self::STATUS_QUEUED; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $resolution = self::RESOLUTION_QUEUED; |
||
84 | |||
85 | /** |
||
86 | * QueuedTask constructor. |
||
87 | * @param string $name |
||
88 | * @param array $params |
||
89 | * @param \DateTime $executeAt |
||
90 | */ |
||
91 | public function __construct($name, array $params = null, \DateTime $executeAt = null) |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function getId() |
||
109 | |||
110 | /** |
||
111 | * @return int |
||
112 | */ |
||
113 | public function getPid() |
||
117 | |||
118 | /** |
||
119 | * @param int $pid |
||
120 | */ |
||
121 | public function setPid(int $pid) |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function getName() |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function getCreated() |
||
141 | |||
142 | /** |
||
143 | * @return \DateTime |
||
144 | */ |
||
145 | public function getUpdated() |
||
149 | |||
150 | /** |
||
151 | * @param \DateTime $updated |
||
152 | */ |
||
153 | public function setUpdated(\DateTime $updated) |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function getExecuteAt() |
||
165 | |||
166 | /** |
||
167 | * {@inheritdoc} |
||
168 | */ |
||
169 | public function getSchedule() |
||
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | public function setSchedule(ScheduleInterface $schedule) |
||
181 | |||
182 | /** |
||
183 | * {@inheritdoc} |
||
184 | */ |
||
185 | public function getParams() |
||
189 | |||
190 | /** |
||
191 | * {@inheritdoc} |
||
192 | */ |
||
193 | public function hasParams() |
||
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | public function getResult() |
||
205 | |||
206 | /** |
||
207 | * {@inheritdoc} |
||
208 | */ |
||
209 | public function getResolution() |
||
213 | |||
214 | /** |
||
215 | * {@inheritdoc} |
||
216 | */ |
||
217 | public function getFinished() |
||
221 | |||
222 | /** |
||
223 | * {@inheritdoc} |
||
224 | */ |
||
225 | public function getStatus() |
||
229 | |||
230 | /** |
||
231 | * {@inheritdoc} |
||
232 | */ |
||
233 | public function getStarted() |
||
237 | |||
238 | /** |
||
239 | * @param \DateTime $started |
||
240 | */ |
||
241 | protected function setStarted(\DateTime $started) |
||
245 | |||
246 | /** |
||
247 | * @param \DateTime $finished |
||
248 | */ |
||
249 | protected function setFinished(\DateTime $finished) |
||
253 | |||
254 | /** |
||
255 | * @param string $status |
||
256 | */ |
||
257 | protected function setStatus($status) |
||
261 | |||
262 | /** |
||
263 | * @param string $resolution |
||
264 | */ |
||
265 | protected function setResolution($resolution) |
||
269 | |||
270 | /** |
||
271 | * @param string $result |
||
272 | */ |
||
273 | protected function setResult($result) |
||
277 | |||
278 | /** |
||
279 | * @param string $resolution |
||
280 | * @param mixed $response |
||
281 | */ |
||
282 | protected function resolve($resolution, $response) |
||
293 | |||
294 | /** |
||
295 | * {@inheritdoc} |
||
296 | */ |
||
297 | public function start() |
||
305 | |||
306 | /** |
||
307 | * {@inheritdoc} |
||
308 | */ |
||
309 | public function success($response) |
||
314 | |||
315 | /** |
||
316 | * {@inheritdoc} |
||
317 | */ |
||
318 | public function failure($response) |
||
323 | |||
324 | /** |
||
325 | * {@inheritdoc} |
||
326 | */ |
||
327 | public function progress(int $progress, ?string $info = null) |
||
335 | } |
||
336 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: