PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.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 / Service / ArchiverDto.php
wp-staging / Backup / Dto / Service Last commit date
ArchiverDto.php 1 day ago DatabaseImporterDto.php 1 day ago
ArchiverDto.php
267 lines
1 <?php
2
3 namespace WPStaging\Backup\Dto\Service;
4
5 use WPStaging\Backup\Entity\BackupMetadata;
6
7 class ArchiverDto
8 {
9
10 private $filePath;
11
12
13 private $indexPath;
14
15
16 private $fileHeaderSizeInBytes = 0;
17
18
19 private $writtenBytesTotal = 0;
20
21
22 private $startOffset = 0;
23
24
25 private $fileSize;
26
27
28 private $indexPositionCreated = [];
29
30
31 private $backupMetadata;
32
33
34
35
36
37
38 private $isContinuation = false;
39
40
41
42
43
44
45 private $sourceBytesWrittenTotal = 0;
46
47
48
49
50
51 public function appendWrittenBytes(int $bytes)
52 {
53 $this->writtenBytesTotal += (int) $bytes;
54 }
55
56
57
58
59 public function isFinished(): bool
60 {
61 return $this->fileSize <= $this->writtenBytesTotal;
62 }
63
64
65
66
67 public function resetIfFinished()
68 {
69 if ($this->isFinished()) {
70 $this->reset();
71 }
72 }
73
74
75
76
77 public function reset()
78 {
79 $this->setFileSize(-1);
80 $this->setFilePath('');
81 $this->setWrittenBytesTotal(0);
82 $this->setIndexPositionCreated(false);
83 $this->setFileHeaderSizeInBytes(0);
84 $this->setStartOffset(0);
85 $this->setIsContinuation(false);
86 $this->setSourceBytesWrittenTotal(0);
87 }
88
89 public function isContinuation(): bool
90 {
91 return $this->isContinuation;
92 }
93
94 public function setIsContinuation(bool $isContinuation)
95 {
96 $this->isContinuation = $isContinuation;
97 }
98
99 public function getSourceBytesWrittenTotal(): int
100 {
101 return $this->sourceBytesWrittenTotal;
102 }
103
104 public function setSourceBytesWrittenTotal(int $sourceBytesWrittenTotal)
105 {
106 $this->sourceBytesWrittenTotal = $sourceBytesWrittenTotal;
107 }
108
109
110
111
112 public function getFilePath(): string
113 {
114 return (string)$this->filePath;
115 }
116
117
118
119
120
121 public function setFilePath(string $filePath)
122 {
123 $this->filePath = wp_normalize_path((string)$filePath);
124 }
125
126
127
128
129 public function getIndexPath(): string
130 {
131 return $this->indexPath;
132 }
133
134
135
136
137
138 public function setIndexPath(string $indexPath)
139 {
140 $this->indexPath = wp_normalize_path((string)$indexPath);
141 }
142
143
144
145
146 public function getWrittenBytesTotal(): int
147 {
148
149 return (int) $this->writtenBytesTotal;
150 }
151
152
153
154
155
156 public function setWrittenBytesTotal(int $writtenBytesTotal)
157 {
158 $this->writtenBytesTotal = $writtenBytesTotal;
159 }
160
161
162
163
164 public function getFileSize(): int
165 {
166 return (int)$this->fileSize;
167 }
168
169
170
171
172
173 public function setFileSize(int $fileSize)
174 {
175 $this->fileSize = $fileSize;
176 }
177
178
179
180
181 public function getFileHeaderSizeInBytes(): int
182 {
183 return $this->fileHeaderSizeInBytes;
184 }
185
186
187
188
189
190 public function setFileHeaderSizeInBytes(int $fileHeaderSizeInBytes)
191 {
192 $this->fileHeaderSizeInBytes = $fileHeaderSizeInBytes;
193 }
194
195
196
197
198
199
200 public function isIndexPositionCreated(string $category = '', int $categoryIndex = 0): bool
201 {
202 if (!isset($this->indexPositionCreated[$category])) {
203 return false;
204 }
205
206 return (bool)$this->indexPositionCreated[$category][$categoryIndex];
207 }
208
209 public function isFileHeaderWritten(): bool
210 {
211 return $this->fileHeaderSizeInBytes > 0;
212 }
213
214
215
216
217
218
219
220 public function setIndexPositionCreated(bool $indexPositionCreated, string $category = '', int $categoryIndex = 0)
221 {
222 if (!isset($this->indexPositionCreated[$category])) {
223 $this->indexPositionCreated[$category] = [];
224 }
225
226 $this->indexPositionCreated[$category][$categoryIndex] = (bool)$indexPositionCreated;
227 }
228
229
230
231
232
233 public function setStartOffset(int $startOffset)
234 {
235 $this->startOffset = $startOffset;
236 }
237
238
239
240
241 public function getStartOffset(): int
242 {
243 return $this->startOffset;
244 }
245
246
247
248
249 public function getBackupMetadata(): BackupMetadata
250 {
251 if (!$this->backupMetadata) {
252 $this->backupMetadata = new BackupMetadata();
253 }
254
255 return $this->backupMetadata;
256 }
257
258
259
260
261
262 public function setBackupMetadata(BackupMetadata $backupMetadata)
263 {
264 $this->backupMetadata = $backupMetadata;
265 }
266 }
267