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,65 @@
<?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\File;
use App\Interface\Test\Composite\FileSystemComponentInterface;
class FileComponent implements FileSystemComponentInterface
{
/**
* 文件名字
* @var string
*/
private string $name;
/**
* 文件大小
* @var int
*/
private int $size;
/**
* 构造方法
* @param string $name
* @param int $size
*/
public function __construct(string $name, int $size)
{
$this->name = $name;
$this->size = $size;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @return int
*/
public function getSize(): int
{
return $this->size;
}
/**
* @param string $prefix
* @return void
*/
public function display(string $prefix = ''): void
{
echo $prefix . ":file:" . $this->name . '(' . $this->size . 'bytes)' . PHP_EOL;
}
}