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