getBasename(), $fileInfo->getSize() ?? 0, $fileInfo->getType() ?? 'N/A', $fileInfo->getPath(), $content, mime_content_type($fileInfo->getFilename()), ); } public function getName(): string { return $this->name; } public function getSize(bool $humanReadable = true): int|string { if (!$humanReadable) { return $this->size; } return $this->getHumanReadableSize(); } public function getType(): string { return $this->type; } public function getPath(): string { return $this->path; } public function getContent(): string { return $this->content; } public function getMimeType(): string { return $this->mimeType; } private function getHumanReadableSize(): string { $bytes = $this->size; $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]); } }