Total Complexity | 5 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4 | enum CompanyStatusEnum: int |
||
5 | { |
||
6 | /** |
||
7 | * 营业中 |
||
8 | */ |
||
9 | case Opening = 0; |
||
10 | |||
11 | /** |
||
12 | * 歇业 |
||
13 | */ |
||
14 | case Closure = 1; |
||
15 | |||
16 | /** |
||
17 | * 闭业 |
||
18 | */ |
||
19 | case Close = 2; |
||
20 | |||
21 | /** |
||
22 | * 清退 |
||
23 | */ |
||
24 | case Out = 3; |
||
25 | |||
26 | public static function fromValue(int $type): self |
||
27 | { |
||
28 | return match ($type) { |
||
29 | 1 => self::Closure, |
||
30 | 2 => self::Close, |
||
31 | 3 => self::Out, |
||
32 | default => self::Opening |
||
33 | }; |
||
34 | } |
||
35 | |||
36 | public function canTrade(): bool |
||
37 | { |
||
38 | return match ($this) { |
||
39 | self::Opening => true, |
||
40 | self::Closure => true, |
||
41 | default => false |
||
42 | }; |
||
43 | } |
||
44 | |||
45 | public function isOpening(): bool |
||
46 | { |
||
47 | return $this === self::Opening; |
||
48 | } |
||
49 | |||
50 | public function isClosure(): bool |
||
53 | } |
||
54 | |||
55 | public function isClose(): bool |
||
58 | } |
||
59 | } |