枚举类:
<?php
namespace App\Enums\Inquiry;
use Rexlabs\Enum\Enum;
/**
*
* Class OrderEnum
* @package App\Enums\Inquiry
* @author songyz <songyz@guahao.com>
* @date 2020/1/16 14:03
*/
class OrderEnum extends Enum{
//接诊状态 1:已完成,2:接诊/问诊中, 9:已取消
const SUCCESS = '1';
const CANCEL = '9';
const PROCESSING = '2';
public static function map() : array
{
return [
static::SUCCESS => '已完成',
static::CANCEL => '已取消',
static::PROCESSING => '问诊中'
];
}
}使用实例


代码实际演示:
dump('keys',OrderStateCountEnum::keys());
dump('names',OrderStateCountEnum::names());
dump('values',OrderStateCountEnum::values());
dump('cachedMap',OrderStateCountEnum::cachedMap());
dump('map',OrderStateCountEnum::map());
dump('namesAndKeys',OrderStateCountEnum::namesAndKeys());"keys"
array:9 [
0 => 99
1 => 1
2 => 0
3 => 2
4 => 3
5 => 10
6 => 9
7 => 8
8 => 7
]
"names"
array:9 [
0 => "WAIT_PAY"
1 => "WAIT_REPLY"
2 => "CONSULT"
3 => "CANCEL"
4 => "COMPLETE"
5 => "BACK"
6 => "CLOSE"
7 => "REFUND"
8 => "WAIT_ADMISSION"
]
"values"
array:9 [
0 => "waitPayCount"
1 => "completeCount"
2 => "waitAdmissionCount"
3 => "consultCount"
4 => "waitReplyCount"
5 => "backCount"
6 => "cancelCount"
7 => "closeCount"
8 => "refundCount"
]
"cachedMap"
array:9 [
99 => "waitPayCount"
1 => "completeCount"
0 => "waitAdmissionCount"
2 => "consultCount"
3 => "waitReplyCount"
10 => "backCount"
9 => "cancelCount"
8 => "closeCount"
7 => "refundCount"
]
"map"
array:9 [
99 => "waitPayCount"
1 => "completeCount"
0 => "waitAdmissionCount"
2 => "consultCount"
3 => "waitReplyCount"
10 => "backCount"
9 => "cancelCount"
8 => "closeCount"
7 => "refundCount"
]
"namesAndKeys"
array:9 [
"WAIT_PAY" => "99"
"WAIT_REPLY" => "3"
"CONSULT" => "2"
"CANCEL" => "9"
"COMPLETE" => "1"
"BACK" => "10"
"CLOSE" => "8"
"REFUND" => "7"
"WAIT_ADMISSION" => "0"
]