<?php

namespace App\Library\Dto;

readonly class MediaFileDto
{
    public function __construct(
        public string $path,
        public string $filename,
        public string $extension,
        public string $size,
    ) {}

    public static function fromSplFileInfo(\SplFileInfo|false $fileInfo): self|false
    {
        return false === $fileInfo ? false : new static(
            path: $fileInfo->getRealPath(),
            filename: $fileInfo->getFilename(),
            extension: $fileInfo->getExtension(),
            size: $fileInfo->getSize(),
        );
    }
}
