|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Glooby\TaskBundle\Model; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @author Emil Kilhage |
|
7
|
|
|
*/ |
|
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 \DateTime |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $result; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var string |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $status = self::STATUS_PENDING; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $resolution = self::RESOLUTION_PENDING; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* QueuedTask constructor. |
|
67
|
|
|
*/ |
|
68
|
|
|
public function __construct() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->created = new \DateTime(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getId(): int |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->id; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritdoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function setId(int $id) |
|
85
|
|
|
{ |
|
86
|
|
|
$this->id = $id; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritdoc} |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getName(): string |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->name; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* {@inheritdoc} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setName(string $name) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->name = $name; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* {@inheritdoc} |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getCreated(): \DateTime |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->created; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* {@inheritdoc} |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setCreated(\DateTime $created) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->created = $created; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* {@inheritdoc} |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getExecuteAt(): \DateTime |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->executeAt; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* {@inheritdoc} |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setExecuteAt(\DateTime $executeAt) |
|
133
|
|
|
{ |
|
134
|
|
|
$this->executeAt = $executeAt; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* {@inheritdoc} |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getSchedule(): ScheduleInterface |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->schedule; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* {@inheritdoc} |
|
147
|
|
|
*/ |
|
148
|
|
|
public function setSchedule(ScheduleInterface $schedule) |
|
149
|
|
|
{ |
|
150
|
|
|
$this->schedule = $schedule; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* {@inheritdoc} |
|
155
|
|
|
*/ |
|
156
|
|
|
public function getParams(): array |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->params; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* {@inheritdoc} |
|
163
|
|
|
*/ |
|
164
|
|
|
public function hasParams(): bool |
|
165
|
|
|
{ |
|
166
|
|
|
return count($this->params) > 0; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* {@inheritdoc} |
|
171
|
|
|
*/ |
|
172
|
|
|
public function setParams(array $params = null) |
|
173
|
|
|
{ |
|
174
|
|
|
$this->params = $params; |
|
|
|
|
|
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* {@inheritdoc} |
|
179
|
|
|
*/ |
|
180
|
|
|
public function getResult() |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->result; |
|
|
|
|
|
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* {@inheritdoc} |
|
187
|
|
|
*/ |
|
188
|
|
|
public function setResult($result) |
|
189
|
|
|
{ |
|
190
|
|
|
$this->result = $result; |
|
|
|
|
|
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* {@inheritdoc} |
|
195
|
|
|
*/ |
|
196
|
|
|
public function getResolution(): string |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->resolution; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* {@inheritdoc} |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setResolution(string $resolution) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->resolution = $resolution; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* {@inheritdoc} |
|
211
|
|
|
*/ |
|
212
|
|
|
public function getFinished(): \DateTime |
|
213
|
|
|
{ |
|
214
|
|
|
return $this->finished; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* {@inheritdoc} |
|
219
|
|
|
*/ |
|
220
|
|
|
public function setFinished(\DateTime $finished) |
|
221
|
|
|
{ |
|
222
|
|
|
$this->finished = $finished; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* {@inheritdoc} |
|
227
|
|
|
*/ |
|
228
|
|
|
public function getStatus(): string |
|
229
|
|
|
{ |
|
230
|
|
|
return $this->status; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* {@inheritdoc} |
|
235
|
|
|
*/ |
|
236
|
|
|
public function setStatus(string $status) |
|
237
|
|
|
{ |
|
238
|
|
|
$this->status = $status; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* {@inheritdoc} |
|
243
|
|
|
*/ |
|
244
|
|
|
public function getStarted(): \DateTime |
|
245
|
|
|
{ |
|
246
|
|
|
return $this->started; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* {@inheritdoc} |
|
251
|
|
|
*/ |
|
252
|
|
|
public function setStarted(\DateTime $started) |
|
253
|
|
|
{ |
|
254
|
|
|
$this->started = $started; |
|
255
|
|
|
} |
|
256
|
|
|
} |
|
257
|
|
|
|
Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.
To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.
The function can be called with either null or an array for the parameter
$needlebut will only accept an array as$haystack.