Upload beautify
This commit is contained in:
23
app/DTOs/Uploads/UploadStoredFile.php
Normal file
23
app/DTOs/Uploads/UploadStoredFile.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user