|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace kalanis\UploadPerPartes\Uploader; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class Data |
|
8
|
|
|
* @package kalanis\UploadPerPartes\Uploader |
|
9
|
|
|
* Driver metadata about processed file |
|
10
|
|
|
*/ |
|
11
|
|
|
final class Data |
|
12
|
|
|
{ |
|
13
|
|
|
public string $tempDir = ''; |
|
14
|
|
|
public string $tempName = ''; |
|
15
|
|
|
public string $targetDir = ''; |
|
16
|
|
|
public string $targetName = ''; |
|
17
|
|
|
/** @var int<0, max> */ |
|
18
|
|
|
public int $fileSize = 0; |
|
19
|
|
|
/** @var int<0, max> */ |
|
20
|
|
|
public int $partsCount = 0; |
|
21
|
|
|
/** @var int<0, max> */ |
|
22
|
|
|
public int $bytesPerPart = 0; |
|
23
|
|
|
/** @var int<0, max> */ |
|
24
|
|
|
public int $lastKnownPart = 0; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string $tempDir |
|
28
|
|
|
* @param string $tempName |
|
29
|
|
|
* @param string $targetDir |
|
30
|
|
|
* @param string $targetName |
|
31
|
|
|
* @param int<0, max> $fileSize |
|
32
|
|
|
* @param int<0, max> $partsCount |
|
33
|
|
|
* @param int<0, max> $bytesPerPart |
|
34
|
|
|
* @param int<0, max> $lastKnownPart |
|
35
|
|
|
* @return $this |
|
36
|
|
|
*/ |
|
37
|
26 |
|
public function setData( |
|
38
|
|
|
string $tempDir, |
|
39
|
|
|
string $tempName, |
|
40
|
|
|
string $targetDir, |
|
41
|
|
|
string $targetName, |
|
42
|
|
|
int $fileSize, |
|
43
|
|
|
int $partsCount = 0, |
|
44
|
|
|
int $bytesPerPart = 0, |
|
45
|
|
|
int $lastKnownPart = 0 |
|
46
|
|
|
): self |
|
47
|
|
|
{ |
|
48
|
26 |
|
$this->tempDir = $tempDir; // where it is during upload |
|
49
|
26 |
|
$this->tempName = $tempName; // what it is during upload |
|
50
|
26 |
|
$this->targetDir = $targetDir; // where it will be stored |
|
51
|
26 |
|
$this->targetName = $targetName; // what name it will have after upload |
|
52
|
26 |
|
$this->fileSize = max(0, $fileSize); // final size |
|
53
|
26 |
|
$this->partsCount = max(0, $partsCount); // is on parts... |
|
54
|
26 |
|
$this->bytesPerPart = max(0, $bytesPerPart); // how long is single part |
|
55
|
26 |
|
$this->lastKnownPart = max(0, $lastKnownPart); // how many parts has been obtained |
|
56
|
26 |
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
19 |
|
public function clear(): self |
|
60
|
|
|
{ |
|
61
|
19 |
|
$this->fileSize = max(0, $this->fileSize); |
|
62
|
19 |
|
$this->partsCount = max(0, $this->partsCount); |
|
63
|
19 |
|
$this->bytesPerPart = max(0, $this->bytesPerPart); |
|
64
|
19 |
|
$this->lastKnownPart = max(0, $this->lastKnownPart); |
|
65
|
19 |
|
return $this; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|