CompanyApplyStatusEnum   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 27
c 1
b 0
f 0
dl 0
loc 77
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A canSubmit() 0 5 1
A isReject() 0 3 1
A isReviewing() 0 3 1
A fromValue() 0 8 1
A isPass() 0 3 1
A canClose() 0 6 1
A canDelete() 0 7 1
1
<?php
2
namespace SimpleCMS\Company\Enums;
3
4
enum CompanyApplyStatusEnum: int
5
{
6
    /**
7
     * 待提交
8
     */
9
    case Pending = 0;
10
11
    /**
12
     * 审核中
13
     */
14
    case Reviewing = 1;
15
16
    /**
17
     * 审核通过
18
     */
19
    case Pass = 2;
20
21
    /**
22
     * 审核拒绝
23
     */
24
    case Reject = 3;
25
26
    /**
27
     * 关闭
28
     */
29
    case Close = 4;
30
31
    public static function fromValue(int $type): self
32
    {
33
        return match ($type) {
34
            1 => self::Reviewing,
35
            2 => self::Pass,
36
            3 => self::Reject,
37
            4 => self::Close,
38
            default => self::Pending
39
        };
40
    }
41
42
    public function canClose(): bool
43
    {
44
        return match ($this) {
45
            self::Reviewing => true,
46
            self::Pending => true,
47
            default => false
48
        };
49
    }
50
    public function canDelete(): bool
51
    {
52
        return match ($this) {
53
            self::Reject => true,
54
            self::Close => true,
55
            self::Pending => true,
56
            default => false
57
        };
58
    }
59
60
    public function canSubmit(): bool
61
    {
62
        return match ($this) {
63
            self::Pending => true,
64
            default => false
65
        };
66
    }
67
68
    public function isPass(): bool
69
    {
70
        return $this === self::Pass;
71
    }
72
73
    public function isReject(): bool
74
    {
75
        return $this === self::Reject;
76
    }
77
78
    public function isReviewing(): bool
79
    {
80
        return $this === self::Reviewing;
81
    }
82
}