65 lines
1.1 KiB
PHP
65 lines
1.1 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\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;
|
|
}
|
|
} |