josantonius / datatype
此包已被废弃且不再维护。未建议替代包。
PHP 简单库,用于管理数据类型。
1.1.6
2018-09-22 10:34 UTC
Requires
- php: ^5.6 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.3 || ^2.8
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^5.7 || ^6.0
- squizlabs/php_codesniffer: ^3.0
README
此库将不再受到支持。另外,您可以使用 Validate 库。
PHP 简单库,用于管理数据类型。
要求
此库支持 PHP 版本 5.6 或更高版本,并且与 HHVM 版本 3.0 或更高版本兼容。
安装
安装此扩展的首选方式是通过 Composer。
要安装 PHP 数据类型库,请执行以下操作
composer require Josantonius/DataType
上述命令只会安装必要的文件,如果您希望 下载整个源代码,则可以使用
composer require Josantonius/DataType --prefer-source
您也可以使用 Git 克隆整个仓库
$ git clone https://github.com/Josantonius/PHP-DataType.git
或者 手动安装它
wget https://raw.githubusercontent.com/Josantonius/PHP-DataType/master/src/DataType.php
可用方法
此库中的可用方法
- 将对象转换为数组
DataType::objectToArray($object);
属性 | 描述 | 类型 | 必需 | 默认 |
---|---|---|---|---|
$object | 对象变量。 | object | 是 |
返回 (array) → 将对象转换为数组
快速入门
要使用此库与 Composer
require __DIR__ . '/vendor/autoload.php'; use Josantonius\DataType\DataType;
如果您已手动安装,则使用它
require_once __DIR__ . '/DataType.php'; use Josantonius\DataType\DataType;
用法
此库的使用示例
$object = new \stdClass(); $object->name = 'Josantonius'; $object->email = 'info@josantonius.com'; $object->url = 'https://github.com/josantonius/PHP-DataType'; echo '<pre>'; var_dump(DataType::objectToArray($object)); echo '</pre>'; /* array(3) { ["name"]=> string(11) "Josantonius" ["email"]=> string(20) "info@josantonius.com" ["url"]=> string(36) "https://github.com/josantonius/PHP-DataType" } */
测试
git clone https://github.com/Josantonius/PHP-DataType.git
cd PHP-DataType
composer install
使用 PHPUnit 运行单元测试
composer phpunit
composer phpcs
使用 PHP Mess Detector 测试以检测代码风格中的不一致性
composer phpmd
运行所有之前的测试
composer tests
赞助商
如果这个项目帮助您减少了开发时间,您可以赞助我以支持我的开源工作 😊
许可协议
本仓库遵循MIT 许可协议。
版权所有 © 2016-2018,Josantonius