PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.8.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.8.2
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Backup / Dto / TaskResponseDto.php
wp-staging / Backup / Dto Last commit date
File 2 years ago Interfaces 2 years ago Job 2 years ago Service 2 years ago Task 2 years ago Traits 1 year ago AbstractDto.php 3 years ago AbstractTaskDto.php 2 years ago JobDataDto.php 2 years ago StepsDto.php 2 years ago TaskResponseDto.php 2 years ago
TaskResponseDto.php
240 lines
1 <?php
2
3 // TODO PHP7.x; declare(strict_type=1);
4 // TODO PHP7.x; type hints & return types
5
6 namespace WPStaging\Backup\Dto;
7
8 use WPStaging\Framework\Traits\ArrayableTrait;
9
10 class TaskResponseDto extends AbstractDto
11 {
12 use ArrayableTrait {
13 toArray as traitToArray;
14 }
15
16 /**
17 * Used to keep old process working, we don't need to hydrate these properties
18 * @var string[]
19 */
20 protected $excludeHydrate = ['last_msg', 'isForceSave', 'job_done'];
21
22 /** @var bool */
23 protected $isRunning;
24
25 /** @var string */
26 protected $jobStatus;
27
28 /** @var int */
29 protected $percentage;
30
31 /** @var int */
32 protected $total;
33
34 /** @var int */
35 protected $step;
36
37 /** @var string */
38 protected $task;
39
40 /** @var string */
41 protected $job;
42
43 /** @var string */
44 protected $statusTitle;
45
46 /** @var array */
47 protected $messages;
48
49 /** @var string */
50 protected $jobId;
51
52 /**
53 * @return array<string, mixed>
54 */
55 public function toArray()
56 {
57 $data = $this->traitToArray();
58
59 $lastMsg = null;
60 if ($data['messages']) {
61 $lastMsg = end($data['messages']);
62 }
63
64 // TODO REF: Remove
65 $data['last_msg'] = $lastMsg;
66 $data['isForceSave'] = true;
67 $data['job_done'] = !$data['isRunning'];
68 return $data;
69 }
70
71 /**
72 * @param string $message
73 */
74 public function addMessage($message)
75 {
76 if (!is_array($this->messages)) {
77 $this->messages = [];
78 }
79
80 $this->messages[] = $message;
81 }
82
83 /**
84 * @return bool
85 */
86 public function isRunning()
87 {
88 return $this->isRunning;
89 }
90
91 /**
92 * @param bool $isRunning
93 */
94 public function setIsRunning($isRunning)
95 {
96 $this->isRunning = $isRunning;
97 }
98
99 /**
100 * @param string $jobStatus
101 */
102 public function setJobStatus($jobStatus)
103 {
104 $this->jobStatus = $jobStatus;
105 }
106
107 /**
108 * @return string
109 */
110 public function getJobStatus()
111 {
112 return $this->jobStatus;
113 }
114
115 /**
116 * @return int
117 */
118 public function getPercentage()
119 {
120 return $this->percentage;
121 }
122
123 /**
124 * @param int $percentage
125 */
126 public function setPercentage($percentage)
127 {
128 $this->percentage = $percentage;
129 }
130
131 /**
132 * @return int
133 */
134 public function getTotal()
135 {
136 return $this->total;
137 }
138
139 /**
140 * @param int $total
141 */
142 public function setTotal($total)
143 {
144 $this->total = $total;
145 }
146
147 /**
148 * @return int
149 */
150 public function getStep()
151 {
152 return $this->step;
153 }
154
155 /**
156 * @param int $step
157 */
158 public function setStep($step)
159 {
160 $this->step = $step;
161 }
162
163 /**
164 * @return string
165 */
166 public function getTask()
167 {
168 return $this->task;
169 }
170
171 /**
172 * @param string $task
173 */
174 public function setTask($task)
175 {
176 $this->task = $task;
177 }
178
179 /**
180 * @return string
181 */
182 public function getJob()
183 {
184 return $this->job;
185 }
186
187 /**
188 * @param string $job
189 */
190 public function setJob($job)
191 {
192 $this->job = $job;
193 }
194
195 /**
196 * @return string
197 */
198 public function getStatusTitle()
199 {
200 return $this->statusTitle;
201 }
202
203 /**
204 * @param string $statusTitle
205 */
206 public function setStatusTitle($statusTitle)
207 {
208 $this->statusTitle = $statusTitle;
209 }
210
211 /**
212 * @return array
213 */
214 public function getMessages()
215 {
216 return $this->messages;
217 }
218
219 public function setMessages(array $messages)
220 {
221 $this->messages = $messages;
222 }
223
224 /**
225 * @return string
226 */
227 public function getJobId()
228 {
229 return $this->jobId;
230 }
231
232 /**
233 * @param string $jobId
234 */
235 public function setJobId($jobId)
236 {
237 $this->jobId = $jobId;
238 }
239 }
240