devysm / enum-mapper
使用枚举映射类将枚举值映射到简短代码。
dev-master
2022-08-21 11:14 UTC
Requires
- php: ^8.0
This package is auto-updated.
Last update: 2024-09-26 11:40:29 UTC
README
使用枚举映射,你可以轻松地将枚举类映射到一些功能。以下命令将解释这些功能。
使用枚举映射类映射你的枚举类。
从某处添加徽章,例如:shields.io
您可以使用以下命令通过composer安装此包。
composer require devysm/enum-mapper
使用/示例
use Devysm\EnumMapper\EnumMapper; $mapper = new EnumMapper(); // This method will return a single array of cassess, Check the next example $mapper->setEnum(\App\Enum\OriginEnum::class)->getCasesWithoutContext(); [ 0 => "italy" 1 => "china" 2 => "turkey" 3 => "germany" 4 => "qatar" 5 => "taiwan" 6 => "japan" ] // This method will return a single array of cassess // with keys like the original value of case, Check the next example. $mapper->setEnum(\App\Enum\OriginEnum::class)->getCasesWithContext(); [ "italy" => "Italy" "china" => "China" "turkey" => "Turkey" "germany" => "Germany" "qatar" => "Qatar" "taiwan" => "Taiwan" "japan" => "Japan" ] // also you can change the context data to lowercase & uppercase // Check the next example $mapper->setEnum(\App\Enum\OriginEnum::class) ->toLowercase() ->getCasesWithContext(); $mapper->setEnum(\App\Enum\OriginEnum::class) ->toUppercase() ->getCasesWithContext();