extalion/php-enum
Composer 安装命令:
composer require extalion/php-enum
包简介
Gives the ability to emulate and create enumeration objects in PHP.
README 文档
README
Gives the ability to emulate and create enumeration objects in PHP.
Install
composer install extalion/php-enum
How to use
Enum definition:
/** * @method static RequestMethod get() * @method static RequestMethod post() */ final class RequestMethod extends \Enum { const VALUES = [ 'get' => 1, 'post' => 2 ]; }
Usage:
function request(string $url, RequestMethod $method, array $data = []) { // ... if ($method === RequestMethod::post()) { \curl_setopt($ch, \CURLOPT_POST, 1); \curl_setopt($ch, \CURLOPT_POSTFIELDS, $data); } // ... }
Tests
php -d zend.assertions=1 test.php
统计信息
- 总下载量: 625
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-09