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 / Staging / Dto / Service / BigFileDto.php
wp-staging / Staging / Dto / Service Last commit date
BigFileDto.php 1 day ago
BigFileDto.php
148 lines
1 <?php
2
3 namespace WPStaging\Staging\Dto\Service;
4
5 class BigFileDto
6 {
7
8 private $filePath = '';
9
10
11 private $destinationPath = '';
12
13
14 private $indexPath = '';
15
16
17 private $writtenBytesTotal = 0;
18
19
20 private $fileSize = -1;
21
22
23
24
25
26 public function appendWrittenBytes(int $bytes)
27 {
28 $this->writtenBytesTotal += (int) $bytes;
29 }
30
31
32
33
34 public function isFinished(): bool
35 {
36 return $this->fileSize <= $this->writtenBytesTotal;
37 }
38
39
40
41
42 public function resetIfFinished()
43 {
44 if ($this->isFinished()) {
45 $this->reset();
46 }
47 }
48
49
50
51
52 public function reset()
53 {
54
55 $this->setFileSize(-1);
56 $this->setFilePath('');
57 $this->setDestinationPath('');
58 $this->setIndexPath('');
59 $this->setWrittenBytesTotal(0);
60 }
61
62
63
64
65 public function getFilePath(): string
66 {
67 return (string)$this->filePath;
68 }
69
70
71
72
73
74 public function setFilePath(string $filePath)
75 {
76 $this->filePath = wp_normalize_path($filePath);
77 }
78
79
80
81
82 public function getDestinationPath(): string
83 {
84 return $this->destinationPath;
85 }
86
87
88
89
90
91 public function setDestinationPath(string $destinationPath)
92 {
93 $this->destinationPath = wp_normalize_path($destinationPath);
94 }
95
96
97
98
99 public function getIndexPath(): string
100 {
101 return $this->indexPath;
102 }
103
104
105
106
107
108 public function setIndexPath(string $indexPath)
109 {
110 $this->indexPath = wp_normalize_path($indexPath);
111 }
112
113
114
115
116 public function getWrittenBytesTotal(): int
117 {
118
119 return (int)$this->writtenBytesTotal;
120 }
121
122
123
124
125
126 public function setWrittenBytesTotal(int $writtenBytesTotal)
127 {
128 $this->writtenBytesTotal = $writtenBytesTotal;
129 }
130
131
132
133
134 public function getFileSize(): int
135 {
136 return (int)$this->fileSize;
137 }
138
139
140
141
142
143 public function setFileSize(int $fileSize)
144 {
145 $this->fileSize = $fileSize;
146 }
147 }
148