mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Data\Extensions;
|
|
|
|
use UnexpectedValueException;
|
|
|
|
final readonly class ExtensionJobSnapshot
|
|
{
|
|
/** @param 'running'|'completed'|'failed' $status */
|
|
public function __construct(
|
|
public string $id,
|
|
public string $extension,
|
|
public string $userUuid,
|
|
public ?string $serverUuid,
|
|
public ?string $permission,
|
|
public string $status,
|
|
public int $percent,
|
|
public string $message,
|
|
public int $sequence,
|
|
public string $updatedAt,
|
|
) {}
|
|
|
|
/** @phpstan-assert self|null $value */
|
|
public static function assertCacheValue(mixed $value): void
|
|
{
|
|
throw_if($value !== null && ! $value instanceof self, UnexpectedValueException::class, 'Invalid cached extension progress snapshot.');
|
|
}
|
|
|
|
/** @return array{id: string, extension: string, status: 'running'|'completed'|'failed', percent: int, message: string, sequence: int, updated_at: string} */
|
|
public function payload(): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'extension' => $this->extension,
|
|
'status' => $this->status,
|
|
'percent' => $this->percent,
|
|
'message' => $this->message,
|
|
'sequence' => $this->sequence,
|
|
'updated_at' => $this->updatedAt,
|
|
];
|
|
}
|
|
}
|