feat : Composite file
This commit is contained in:
40
app/Service/Test/Composite/FileService.php
Normal file
40
app/Service/Test/Composite/FileService.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user