Upload beautify
This commit is contained in:
46
app/Uploads/Services/InspectionResult.php
Normal file
46
app/Uploads/Services/InspectionResult.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Uploads\Services;
|
||||
|
||||
final class InspectionResult
|
||||
{
|
||||
/**
|
||||
* @param array{files:int,depth:int,size:int,ratio:float} $stats
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly bool $valid,
|
||||
public readonly ?string $reason,
|
||||
public readonly array $stats,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{files:int,depth:int,size:int,ratio:float} $stats
|
||||
*/
|
||||
public static function pass(array $stats): self
|
||||
{
|
||||
return new self(true, null, $stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{files:int,depth:int,size:int,ratio:float} $stats
|
||||
*/
|
||||
public static function fail(string $reason, array $stats): self
|
||||
{
|
||||
return new self(false, $reason, $stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{valid:bool,reason:?string,stats:array{files:int,depth:int,size:int,ratio:float}}
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'valid' => $this->valid,
|
||||
'reason' => $this->reason,
|
||||
'stats' => $this->stats,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user