evaisse/php-simple-enum
Composer 安装命令:
composer require evaisse/php-simple-enum
包简介
A very stupid, basic, enum control struct for php
README 文档
README
A Simple ENUM utils, to ensure inputs are compliant with your some basic data structs.
composer require evaisse/php-simple-enum
Allow to fetch a static list of values from givens constants :
use evaisse\PhpSimpleEnum\PhpEnum; $enumInt = new PhpEnum([ 'FOO' => 1, 'BAR' => 2, ]); $enum = PhpEnum::fromConstants('\Symfony\Component\HttpFoundation\Request::METHOD_*'); $enum->getAllowedValues(); /* [ 'GET', 'POST', ... ] */ /* * Fetch enum name for a given value */ assert($enum->getKeyForValue(\Symfony\Component\HttpFoundation\Request::METHOD_GET) === 'METHOD_GET'); /* * test value */ $enum->isAllowed('GET'); // true /* * fetch and assign, or throw invalid argument exception */ $param = $enum->validate($_GET['askedValue']); /* * Fetch the whole dictonary */ $enum->getHash(); /* [ 'METHOD_GET' => 'GET', ... ] */
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-27