Upload beautify
This commit is contained in:
14
app/DTOs/Artworks/ArtworkDraftResult.php
Normal file
14
app/DTOs/Artworks/ArtworkDraftResult.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Artworks;
|
||||
|
||||
final class ArtworkDraftResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $artworkId,
|
||||
public readonly string $status
|
||||
) {
|
||||
}
|
||||
}
|
||||
17
app/DTOs/Uploads/UploadChunkResult.php
Normal file
17
app/DTOs/Uploads/UploadChunkResult.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
final class UploadChunkResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $sessionId,
|
||||
public readonly string $status,
|
||||
public readonly int $receivedBytes,
|
||||
public readonly int $totalBytes,
|
||||
public readonly int $progress
|
||||
) {
|
||||
}
|
||||
}
|
||||
15
app/DTOs/Uploads/UploadInitResult.php
Normal file
15
app/DTOs/Uploads/UploadInitResult.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
final class UploadInitResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $sessionId,
|
||||
public readonly string $token,
|
||||
public readonly string $status
|
||||
) {
|
||||
}
|
||||
}
|
||||
24
app/DTOs/Uploads/UploadScanResult.php
Normal file
24
app/DTOs/Uploads/UploadScanResult.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
final class UploadScanResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly bool $ok,
|
||||
public readonly string $reason
|
||||
) {
|
||||
}
|
||||
|
||||
public static function clean(): self
|
||||
{
|
||||
return new self(true, '');
|
||||
}
|
||||
|
||||
public static function infected(string $reason): self
|
||||
{
|
||||
return new self(false, $reason);
|
||||
}
|
||||
}
|
||||
22
app/DTOs/Uploads/UploadSessionData.php
Normal file
22
app/DTOs/Uploads/UploadSessionData.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
final class UploadSessionData
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $id,
|
||||
public readonly int $userId,
|
||||
public readonly string $tempPath,
|
||||
public readonly string $status,
|
||||
public readonly string $ip,
|
||||
public readonly CarbonImmutable $createdAt,
|
||||
public readonly int $progress,
|
||||
public readonly ?string $failureReason
|
||||
) {
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
14
app/DTOs/Uploads/UploadValidatedFile.php
Normal file
14
app/DTOs/Uploads/UploadValidatedFile.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
final class UploadValidatedFile
|
||||
{
|
||||
public function __construct(
|
||||
public readonly UploadValidationResult $validation,
|
||||
public readonly ?string $hash
|
||||
) {
|
||||
}
|
||||
}
|
||||
28
app/DTOs/Uploads/UploadValidationResult.php
Normal file
28
app/DTOs/Uploads/UploadValidationResult.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\DTOs\Uploads;
|
||||
|
||||
final class UploadValidationResult
|
||||
{
|
||||
public function __construct(
|
||||
public readonly bool $ok,
|
||||
public readonly string $reason,
|
||||
public readonly ?int $width,
|
||||
public readonly ?int $height,
|
||||
public readonly ?string $mime,
|
||||
public readonly ?int $size
|
||||
) {
|
||||
}
|
||||
|
||||
public static function ok(int $width, int $height, string $mime, int $size): self
|
||||
{
|
||||
return new self(true, '', $width, $height, $mime, $size);
|
||||
}
|
||||
|
||||
public static function fail(string $reason, ?int $width = null, ?int $height = null, ?string $mime = null, ?int $size = null): self
|
||||
{
|
||||
return new self(false, $reason, $width, $height, $mime, $size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user