1 | <?php |
||
8 | class QueuedTask implements QueuedTaskInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var int |
||
12 | */ |
||
13 | protected $id; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $name; |
||
19 | |||
20 | /** |
||
21 | * @var \DateTime |
||
22 | */ |
||
23 | protected $created; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $params = []; |
||
29 | |||
30 | /** |
||
31 | * @var ScheduleInterface |
||
32 | */ |
||
33 | protected $schedule; |
||
34 | |||
35 | /** |
||
36 | * @var \DateTime |
||
37 | */ |
||
38 | protected $executeAt; |
||
39 | |||
40 | /** |
||
41 | * @var \DateTime |
||
42 | */ |
||
43 | protected $started; |
||
44 | |||
45 | /** |
||
46 | * @var \DateTime |
||
47 | */ |
||
48 | protected $finished; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $result; |
||
54 | |||
55 | /** |
||
56 | * @var int |
||
57 | */ |
||
58 | protected $progress; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $progressInfo; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $status = self::STATUS_QUEUED; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $resolution = self::RESOLUTION_QUEUED; |
||
74 | |||
75 | /** |
||
76 | * QueuedTask constructor. |
||
77 | * @param string $name |
||
78 | * @param array $params |
||
79 | * @param \DateTime $executeAt |
||
80 | */ |
||
81 | public function __construct($name, array $params = null, \DateTime $executeAt = null) |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function getId() |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function getName() |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | public function getCreated() |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | public function getExecuteAt() |
||
122 | |||
123 | /** |
||
124 | * {@inheritdoc} |
||
125 | */ |
||
126 | public function getSchedule() |
||
130 | |||
131 | /** |
||
132 | * {@inheritdoc} |
||
133 | */ |
||
134 | public function setSchedule(ScheduleInterface $schedule) |
||
138 | |||
139 | /** |
||
140 | * {@inheritdoc} |
||
141 | */ |
||
142 | public function getParams() |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | public function hasParams() |
||
154 | |||
155 | /** |
||
156 | * {@inheritdoc} |
||
157 | */ |
||
158 | public function getResult() |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function getResolution() |
||
170 | |||
171 | /** |
||
172 | * {@inheritdoc} |
||
173 | */ |
||
174 | public function getFinished() |
||
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | public function getStatus() |
||
186 | |||
187 | /** |
||
188 | * {@inheritdoc} |
||
189 | */ |
||
190 | public function getStarted() |
||
194 | |||
195 | /** |
||
196 | * @param \DateTime $started |
||
197 | */ |
||
198 | protected function setStarted(\DateTime $started) |
||
202 | |||
203 | /** |
||
204 | * @param \DateTime $finished |
||
205 | */ |
||
206 | protected function setFinished(\DateTime $finished) |
||
210 | |||
211 | /** |
||
212 | * @param string $status |
||
213 | */ |
||
214 | protected function setStatus($status) |
||
218 | |||
219 | /** |
||
220 | * @param string $resolution |
||
221 | */ |
||
222 | protected function setResolution($resolution) |
||
226 | |||
227 | /** |
||
228 | * @param string $result |
||
229 | */ |
||
230 | protected function setResult($result) |
||
234 | |||
235 | /** |
||
236 | * @param string $resolution |
||
237 | * @param mixed $response |
||
238 | */ |
||
239 | protected function resolve($resolution, $response) |
||
249 | |||
250 | /** |
||
251 | * {@inheritdoc} |
||
252 | */ |
||
253 | public function start() |
||
259 | |||
260 | /** |
||
261 | * {@inheritdoc} |
||
262 | */ |
||
263 | public function success($response) |
||
268 | |||
269 | /** |
||
270 | * {@inheritdoc} |
||
271 | */ |
||
272 | public function failure($response) |
||
277 | |||
278 | /** |
||
279 | * {@inheritdoc} |
||
280 | */ |
||
281 | public function progress(int $progress, ?string $info = null) |
||
289 | } |
||
290 |
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: