<?php

declare(strict_types=1);

namespace App\DTOs\Uploads;

final class UploadStoredFile
{
    public function __construct(
        public readonly string $path,
        public readonly int $size,
        public readonly string $extension
    ) {
    }

    public static function fromPath(string $path): self
    {
        $size = is_file($path) ? (int) filesize($path) : 0;
        $extension = (string) pathinfo($path, PATHINFO_EXTENSION);

        return new self($path, $size, $extension);
    }
}
