CompanyStatusEnum   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 17
c 1
b 0
f 0
dl 0
loc 54
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isClosure() 0 3 1
A canTrade() 0 6 1
A fromValue() 0 7 1
A isClose() 0 3 1
A isOpening() 0 3 1
1
<?php
2
namespace SimpleCMS\Company\Enums;
3
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
51
    {
52
        return $this === self::Closure;
53
    }
54
55
    public function isClose(): bool
56
    {
57
        return $this === self::Close;
58
    }
59
}