123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace App\Enums;
- enum SysAuditStatus: int
- {
-
- case PENDING = 1;
-
- case PASSED = 2;
-
- case REJECTED = 3;
-
- public function label(): string
- {
- return match ($this) {
- self::PENDING => '待审核',
- self::PASSED => '通过',
- self::REJECTED => '拒绝',
- };
- }
-
- public function value(): int
- {
- return $this->value;
- }
-
- public function is(self $status): bool
- {
- return $this === $status;
- }
-
- public static function fromValue(int $value): ?self
- {
- return match ($value) {
- self::PENDING->value => self::PENDING,
- self::PASSED->value => self::PASSED,
- self::REJECTED->value => self::REJECTED,
- default => null
- };
- }
-
- public static function values(): array
- {
- return array_column(self::cases(), 'value');
- }
-
- public static function all(): array
- {
- return [
- self::PENDING->value => self::PENDING->label(),
- self::PASSED->value => self::PASSED->label(),
- self::REJECTED->value => self::REJECTED->label(),
- ];
- }
- }
|