|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace kalanis\UploadPerPartes\Uploader; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use kalanis\UploadPerPartes\Interfaces; |
|
7
|
|
|
use kalanis\UploadPerPartes\Target\Local; |
|
8
|
|
|
use kalanis\UploadPerPartes\Target\Local\DrivingFile; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class Config |
|
13
|
|
|
* @package kalanis\UploadPerPartes\Uploader |
|
14
|
|
|
* Configuration of the whole uploader |
|
15
|
|
|
*/ |
|
16
|
|
|
final class Config |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var int<0, max> */ |
|
19
|
|
|
public int $bytesPerPart = 0; |
|
20
|
|
|
public bool $canContinue = true; |
|
21
|
|
|
public string $tempDir = ''; |
|
22
|
|
|
public string $targetDir = ''; |
|
23
|
|
|
/** @var string|Interfaces\IUppTranslations|null */ |
|
24
|
|
|
public $lang = null; |
|
25
|
|
|
/** @var string|Interfaces\IOperations|null */ |
|
26
|
|
|
public $target = null; |
|
27
|
|
|
/** @var string|DrivingFile\DataEncoders\AEncoder|null */ |
|
28
|
|
|
public $dataEncoder = null; |
|
29
|
|
|
/** @var string|DrivingFile\DataModifiers\AModifier|null */ |
|
30
|
|
|
public $dataModifier = null; |
|
31
|
|
|
/** @var string|DrivingFile\KeyEncoders\AEncoder|null */ |
|
32
|
|
|
public $keyEncoder = null; |
|
33
|
|
|
/** @var string|DrivingFile\KeyModifiers\AModifier|null */ |
|
34
|
|
|
public $keyModifier = null; |
|
35
|
|
|
/** @var int|string|object|null */ |
|
36
|
|
|
public $drivingFileStorage = null; |
|
37
|
|
|
/** @var int|string|object|null */ |
|
38
|
|
|
public $temporaryStorage = null; |
|
39
|
|
|
/** @var string|Local\TemporaryStorage\KeyEncoders\AEncoder|null */ |
|
40
|
|
|
public $temporaryEncoder = null; |
|
41
|
|
|
/** @var int|string|object|null */ |
|
42
|
|
|
public $finalStorage = null; |
|
43
|
|
|
/** @var string|Local\FinalStorage\KeyEncoders\AEncoder|null */ |
|
44
|
|
|
public $finalEncoder = null; |
|
45
|
|
|
/** @var string|null */ |
|
46
|
|
|
public ?string $checksum = null; |
|
47
|
|
|
/** @var string|null */ |
|
48
|
|
|
public ?string $decoder = null; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param array<string, string|int|bool|object|array<string|int|bool|object>|null> $params |
|
52
|
|
|
*/ |
|
53
|
170 |
|
public function __construct(array $params) |
|
54
|
|
|
{ |
|
55
|
170 |
|
if (isset($params['calc_size'])) { |
|
56
|
21 |
|
$this->bytesPerPart = max(1, intval($params['calc_size'])); |
|
57
|
|
|
} |
|
58
|
170 |
|
if (isset($params['temp_location'])) { |
|
59
|
21 |
|
$this->tempDir = strval($params['temp_location']); |
|
60
|
|
|
} |
|
61
|
170 |
|
if (isset($params['target_location'])) { |
|
62
|
3 |
|
$this->targetDir = strval($params['target_location']); |
|
63
|
|
|
} |
|
64
|
170 |
|
if (isset($params['lang'])) { |
|
65
|
3 |
|
if (is_object($params['lang'])) { |
|
66
|
2 |
|
if ($params['lang'] instanceof Interfaces\IUppTranslations) { |
|
67
|
2 |
|
$this->lang = $params['lang']; |
|
68
|
|
|
} |
|
69
|
|
|
} else { |
|
70
|
1 |
|
$this->lang = strval($params['lang']); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
170 |
|
if (isset($params['target'])) { |
|
74
|
15 |
|
if (is_object($params['target'])) { |
|
75
|
14 |
|
if ($params['target'] instanceof Interfaces\IOperations) { |
|
76
|
14 |
|
$this->target = $params['target']; |
|
77
|
|
|
} |
|
78
|
|
|
} else { |
|
79
|
1 |
|
$this->target = strval($params['target']); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
170 |
|
if (isset($params['data_encoder'])) { |
|
83
|
25 |
|
if (is_object($params['data_encoder'])) { |
|
84
|
20 |
|
if ($params['data_encoder'] instanceof DrivingFile\DataEncoders\AEncoder) { |
|
85
|
20 |
|
$this->dataEncoder = $params['data_encoder']; |
|
86
|
|
|
} |
|
87
|
|
|
} else { |
|
88
|
5 |
|
$this->dataEncoder = strval($params['data_encoder']); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
170 |
|
if (isset($params['data_modifier'])) { |
|
92
|
22 |
|
if (is_object($params['data_modifier'])) { |
|
93
|
19 |
|
if ($params['data_modifier'] instanceof DrivingFile\DataModifiers\AModifier) { |
|
94
|
19 |
|
$this->dataModifier = $params['data_modifier']; |
|
95
|
|
|
} |
|
96
|
|
|
} else { |
|
97
|
3 |
|
$this->dataModifier = strval($params['data_modifier']); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
170 |
|
if (isset($params['key_encoder'])) { |
|
101
|
25 |
|
if (is_object($params['key_encoder'])) { |
|
102
|
20 |
|
if ($params['key_encoder'] instanceof DrivingFile\KeyEncoders\AEncoder) { |
|
103
|
20 |
|
$this->keyEncoder = $params['key_encoder']; |
|
104
|
|
|
} |
|
105
|
|
|
} else { |
|
106
|
5 |
|
$this->keyEncoder = strval($params['key_encoder']); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
170 |
|
if (isset($params['key_modifier'])) { |
|
110
|
22 |
|
if (is_object($params['key_modifier'])) { |
|
111
|
19 |
|
if ($params['key_modifier'] instanceof DrivingFile\KeyModifiers\AModifier) { |
|
112
|
19 |
|
$this->keyModifier = $params['key_modifier']; |
|
113
|
|
|
} |
|
114
|
|
|
} else { |
|
115
|
3 |
|
$this->keyModifier = strval($params['key_modifier']); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
170 |
|
if (isset($params['driving_file'])) { |
|
119
|
27 |
|
if (!is_array($params['driving_file']) && !is_bool($params['driving_file'])) { |
|
120
|
27 |
|
$this->drivingFileStorage = $params['driving_file']; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
170 |
|
if (isset($params['temp_storage'])) { |
|
124
|
24 |
|
if (!is_array($params['temp_storage']) && !is_bool($params['temp_storage'])) { |
|
125
|
24 |
|
$this->temporaryStorage = $params['temp_storage']; |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
170 |
|
if (isset($params['temp_encoder'])) { |
|
129
|
23 |
|
if (is_object($params['temp_encoder'])) { |
|
130
|
20 |
|
if ($params['temp_encoder'] instanceof Local\TemporaryStorage\KeyEncoders\AEncoder) { |
|
131
|
20 |
|
$this->temporaryEncoder = $params['temp_encoder']; |
|
132
|
|
|
} |
|
133
|
|
|
} else { |
|
134
|
3 |
|
$this->temporaryEncoder = strval($params['temp_encoder']); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
170 |
|
if (isset($params['final_storage'])) { |
|
138
|
24 |
|
if (!is_array($params['final_storage']) && !is_bool($params['final_storage'])) { |
|
139
|
24 |
|
$this->finalStorage = $params['final_storage']; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
170 |
|
if (isset($params['final_encoder'])) { |
|
143
|
23 |
|
if (is_object($params['final_encoder'])) { |
|
144
|
20 |
|
if ($params['final_encoder'] instanceof Local\FinalStorage\KeyEncoders\AEncoder) { |
|
145
|
20 |
|
$this->finalEncoder = $params['final_encoder']; |
|
146
|
|
|
} |
|
147
|
|
|
} else { |
|
148
|
3 |
|
$this->finalEncoder = strval($params['final_encoder']); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
170 |
|
if (isset($params['checksum'])) { |
|
152
|
3 |
|
$this->checksum = strval($params['checksum']); |
|
153
|
|
|
} |
|
154
|
170 |
|
if (isset($params['decoder'])) { |
|
155
|
20 |
|
$this->decoder = strval($params['decoder']); |
|
156
|
|
|
} |
|
157
|
170 |
|
$this->canContinue = isset($params['can_continue']) ? boolval(intval(strval($params['can_continue']))) : true; |
|
158
|
170 |
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|