1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
declare(strict_types=1);
namespace Nsfisis\Albatross\Models;
enum ExecutionStatus: string
{
case Pending = 'Pending';
case Running = 'Running';
case IE = 'IE';
case RE = 'RE';
case WA = 'WA';
case TLE = 'TLE';
case AC = 'AC';
public function label(): string
{
return match ($this) {
self::Pending => '実行待機中',
self::Running => '実行中',
self::IE => '内部エラー',
self::RE => '実行時エラー',
self::WA => '不正解',
self::TLE => '時間制限超過',
self::AC => 'OK',
};
}
public function showLoadingIndicator(): bool
{
return match ($this) {
self::Pending => true,
self::Running => true,
self::IE => false,
self::RE => false,
self::WA => false,
self::TLE => false,
self::AC => false,
};
}
public function toInt(): int
{
return match ($this) {
self::Pending => 0,
self::Running => 1,
self::IE => 2,
self::RE => 3,
self::WA => 4,
self::TLE => 5,
self::AC => 6,
};
}
public static function fromInt(int $n): self
{
// @phpstan-ignore-next-line
return match ($n) {
0 => self::Pending,
1 => self::Running,
2 => self::IE,
3 => self::RE,
4 => self::WA,
5 => self::TLE,
6 => self::AC,
};
}
public static function fromString(string $s): self
{
// @phpstan-ignore-next-line
return match ($s) {
'Pending' => self::Pending,
'Running' => self::Running,
'IE' => self::IE,
'RE' => self::RE,
'WA' => self::WA,
'TLE' => self::TLE,
'AC' => self::AC,
};
}
}
|