2023-10-02 23:10:49 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Lucent\Record;
|
|
|
|
|
|
|
|
|
|
|
2024-08-19 17:48:10 +03:00
|
|
|
class FileData
|
2023-10-02 23:10:49 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
function __construct(
|
|
|
|
|
public readonly string $originalName,
|
|
|
|
|
public readonly string $mime,
|
|
|
|
|
public readonly string $path,
|
2024-09-20 13:39:45 +03:00
|
|
|
public readonly string $disk,
|
2023-10-02 23:10:49 +03:00
|
|
|
public readonly int $size,
|
|
|
|
|
public readonly int $width,
|
|
|
|
|
public readonly int $height,
|
|
|
|
|
public readonly string $checksum,
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-19 17:48:10 +03:00
|
|
|
public static function fromArray(array $data): FileData
|
2023-10-02 23:10:49 +03:00
|
|
|
{
|
2024-08-19 17:48:10 +03:00
|
|
|
return new FileData(
|
2023-10-02 23:10:49 +03:00
|
|
|
originalName: data_get($data, "originalName"),
|
|
|
|
|
mime: data_get($data, "mime"),
|
|
|
|
|
path: data_get($data, "path"),
|
2024-09-20 13:39:45 +03:00
|
|
|
disk: data_get($data, "disk", "lucent"),
|
2023-10-02 23:10:49 +03:00
|
|
|
size: data_get($data, "size"),
|
|
|
|
|
width: data_get($data, "width"),
|
|
|
|
|
height: data_get($data, "height"),
|
|
|
|
|
checksum: data_get($data, "checksum"),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toArray(): array
|
|
|
|
|
{
|
|
|
|
|
return \json_decode(\json_encode($this), true);
|
|
|
|
|
}
|
|
|
|
|
}
|