Files
hyperf_test/app/Service/Test/Composite/FileService.php
2025-09-07 19:36:04 +08:00

40 lines
1.0 KiB
PHP

<?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();
}
}