feat : Composite file

This commit is contained in:
2025-09-07 19:36:04 +08:00
parent b106c4a352
commit 714baffaf7
10 changed files with 302 additions and 2 deletions

View File

@@ -0,0 +1,40 @@
<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
* @web_site https://ctexthuang.com
*/
declare(strict_types=1);
namespace App\Service\Test\Composite;
use App\Service\Test\Composite\File\DirectoryComponent;
use App\Service\Test\Composite\File\FileComponent;
use App\Service\Test\TestBaseService;
class FileService extends TestBaseService
{
/**
* @return array
*/
public function handle(): array
{
$root = new DirectoryComponent('root');
$documents = new DirectoryComponent('documents');
$images = new DirectoryComponent('images');
$file1 = new FileComponent('readme.md',1024);
$file2 = new FileComponent('report.pdf',2048);
$file3 = new FileComponent('photo.jpg',4096);
$root->add($documents);
$root->add($images);
$documents->add($file1);
$documents->add($file2);
$images->add($file3);
$root->display();
return $this->return->success();
}
}