1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pheanstalk\Structure; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* A job in a EvQueue server. |
7
|
|
|
* |
8
|
|
|
* @author Valentin Corre |
9
|
|
|
* @package Pheanstalk |
10
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php |
11
|
|
|
*/ |
12
|
|
|
class TaskInstance extends Task |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** @var int $contextId */ |
16
|
|
|
protected $contextId; |
17
|
|
|
|
18
|
|
|
/** @var int $evqid */ |
19
|
|
|
protected $evqid; |
20
|
|
|
|
21
|
|
|
/** @var \DateTime $execution_time */ |
22
|
|
|
protected $execution_time; |
23
|
|
|
|
24
|
|
|
/** @var int $pid */ |
25
|
|
|
protected $pid; |
26
|
|
|
|
27
|
|
|
/** @var int $progression */ |
28
|
|
|
protected $progression; |
29
|
|
|
|
30
|
|
|
/** @var string $status */ |
31
|
|
|
protected $status; |
32
|
|
|
|
33
|
|
|
/** @var int $tid */ |
34
|
|
|
protected $tid; |
35
|
|
|
|
36
|
7 |
|
public function __construct(array $params) |
37
|
|
|
{ |
38
|
7 |
|
$thisObject = new \ReflectionClass($this); |
39
|
7 |
|
$properties = $thisObject->getProperties(); |
40
|
7 |
|
foreach ($properties as $property) { |
41
|
7 |
|
$snakeProperty = $this->from_camel_case($property->getName()); |
42
|
7 |
|
if (isset($params[$snakeProperty])) { |
43
|
3 |
|
$this->{$property->getName()} = $params[$snakeProperty]; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return int |
50
|
|
|
*/ |
51
|
|
|
public function getContextId(): int |
52
|
|
|
{ |
53
|
|
|
return $this->contextId; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param int $contextId |
58
|
|
|
* |
59
|
|
|
* @return TaskInstance |
60
|
|
|
*/ |
61
|
|
|
public function setContextId(int $contextId): TaskInstance |
62
|
|
|
{ |
63
|
|
|
$this->contextId = $contextId; |
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return int |
69
|
|
|
*/ |
70
|
|
|
public function getEvqid(): int |
71
|
|
|
{ |
72
|
|
|
return $this->evqid; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param int $evqid |
77
|
|
|
* |
78
|
|
|
* @return TaskInstance |
79
|
|
|
*/ |
80
|
|
|
public function setEvqid(int $evqid): TaskInstance |
81
|
|
|
{ |
82
|
|
|
$this->evqid = $evqid; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return \DateTime |
88
|
|
|
*/ |
89
|
|
|
public function getExecutionTime(): \DateTime |
90
|
|
|
{ |
91
|
|
|
return $this->execution_time; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param \DateTime $execution_time |
96
|
|
|
* |
97
|
|
|
* @return TaskInstance |
98
|
|
|
*/ |
99
|
|
|
public function setExecutionTime(\DateTime $execution_time): TaskInstance |
100
|
|
|
{ |
101
|
|
|
$this->execution_time = $execution_time; |
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return int |
107
|
|
|
*/ |
108
|
1 |
|
public function getPid(): int |
109
|
|
|
{ |
110
|
1 |
|
return $this->pid; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param int $pid |
115
|
|
|
* |
116
|
|
|
* @return TaskInstance |
117
|
|
|
*/ |
118
|
|
|
public function setPid(int $pid): TaskInstance |
119
|
|
|
{ |
120
|
|
|
$this->pid = $pid; |
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return int |
126
|
|
|
*/ |
127
|
|
|
public function getProgression(): int |
128
|
|
|
{ |
129
|
|
|
return $this->progression; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param int $progression |
134
|
|
|
* |
135
|
|
|
* @return TaskInstance |
136
|
|
|
*/ |
137
|
|
|
public function setProgression(int $progression): TaskInstance |
138
|
|
|
{ |
139
|
|
|
$this->progression = $progression; |
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
public function getStatus(): string |
147
|
|
|
{ |
148
|
|
|
return $this->status; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param string $status |
153
|
|
|
* |
154
|
|
|
* @return TaskInstance |
155
|
|
|
*/ |
156
|
|
|
public function setStatus(string $status): TaskInstance |
157
|
|
|
{ |
158
|
|
|
$this->status = $status; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return int |
164
|
|
|
*/ |
165
|
|
|
public function getTid(): int |
166
|
|
|
{ |
167
|
|
|
return $this->tid; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param int $tid |
172
|
|
|
* |
173
|
|
|
* @return TaskInstance |
174
|
|
|
*/ |
175
|
|
|
public function setTid(int $tid): TaskInstance |
176
|
|
|
{ |
177
|
|
|
$this->tid = $tid; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|