diff --git a/src/Objects/DirContent.php b/src/Objects/DirContent.php index 03e07e3..342a6fd 100644 --- a/src/Objects/DirContent.php +++ b/src/Objects/DirContent.php @@ -6,14 +6,14 @@ namespace App\Objects; use SplFileInfo; -class DirContent +readonly class DirContent { private function __construct( - private readonly string $name, - private readonly int $size, - private readonly string $type, - ) - { + private string $name, + private int $size, + private string $type, + private string $path, + ) { } public static function make(SplFileInfo $fileInfo): DirContent @@ -22,6 +22,7 @@ class DirContent $fileInfo->getBasename(), $fileInfo->getSize() ?? 0, $fileInfo->getType() ?? 'N/A', + $fileInfo->getPath(), ); } @@ -44,10 +45,15 @@ class DirContent return $this->type; } - private function getHumanReadableSize() + public function getPath(): string + { + return $this->path; + } + + private function getHumanReadableSize(): string { $bytes = $this->size; - $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); + $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = floor((strlen((string) $bytes) - 1) / 3); return sprintf("%.1f %s", $bytes / (1024 ** $factor), $size[$factor]);