Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ManagementControlBackupListLogic | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
validateImpl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
executeImpl | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\ManagementControl; |
6 | |
7 | use PeServer\App\Models\Domain\AppArchiver; |
8 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
9 | use PeServer\Core\Collection\Arr; |
10 | use PeServer\Core\Collection\OrderBy; |
11 | use PeServer\Core\IO\File; |
12 | use PeServer\Core\IO\Path; |
13 | use PeServer\Core\Mvc\LogicCallMode; |
14 | use PeServer\Core\Mvc\LogicParameter; |
15 | use PeServer\Core\SizeConverter; |
16 | |
17 | class ManagementControlBackupListLogic extends PageLogicBase |
18 | { |
19 | public function __construct(LogicParameter $parameter, private AppArchiver $appArchiver) |
20 | { |
21 | parent::__construct($parameter); |
22 | } |
23 | |
24 | protected function validateImpl(LogicCallMode $callMode): void |
25 | { |
26 | //NOP |
27 | } |
28 | |
29 | protected function executeImpl(LogicCallMode $callMode): void |
30 | { |
31 | $files = Arr::sortByValue($this->appArchiver->getFiles(), OrderBy::Descending); |
32 | $sizeConverter = new SizeConverter(); |
33 | /** @var array<array{name:string,size:int}> */ |
34 | $items = []; |
35 | foreach ($files as $file) { |
36 | $fileSize = File::getFileSize($file); |
37 | $item = [ |
38 | 'name' => Path::getFileName($file), |
39 | 'size' => $fileSize, |
40 | 'human_size' => $sizeConverter->convertHumanReadableByte($fileSize, '{f_size} {unit}'), |
41 | ]; |
42 | $items[] = $item; |
43 | } |
44 | |
45 | $this->setValue('items', $items); |
46 | $this->setValue('directory', $this->appArchiver->getDirectory()); |
47 | } |
48 | } |