drupol / valuewrapper
此库允许您将任何类型的PHP变量包装在严格的PHP对象中。
1.2.0
2019-07-09 07:29 UTC
Requires
- php: >= 7.1
- ext-json: *
- jeremeamia/superclosure: ^2
Requires (Dev)
- drupol/php-conventions: ^1
- drupol/phpspec-annotation: ^1
- drupol/phpspec-code-coverage: ^4 || ^5
- infection/infection: ^0.13
- phpspec/phpspec: ^4 || ^5
- scrutinizer/ocular: ^1
README
ValueWrapper
描述
此库允许您将PHP变量包装在严格的PHP对象中。
文档
待办事项。
要求
- PHP >= 7.1
安装
composer require drupol/valuewrapper
使用
$string = 'Hello world!'; $value = ValueWrapper::create($string); // This creates a StringType object. $integer = 123; $value = ValueWrapper::create($integer); // This creates an IntegerType object. $closure = function (string $who) {return 'Hello ' . $who;}; $value = ValueWrapper::create($closure); // This creates a ClosureObject object. $value('world'); // Return 'Hello world'. $value->hash(); // Return '513c4a7d0c1e07fa75e40c842880c82cffa69c5d'. $anotherClosure = function () {return 'Hello world';}; $anotherValue = ValueWrapper::create($anotherClosure); $value->equals($anotherValue); // Return false. $sameClosure = function (string $who) {return 'Hello ' . $who;}; $sameValue = ValueWrapper::create($sameClosure); $value->equals($sameValue); // Return true.
代码质量和测试
每次向库中引入更改时,Github都会运行测试。
库中有使用PHPSpec编写的测试。
请随意在spec
目录中查看它们。运行composer phpspec
以触发测试。
PHPInfection用于确保您的代码经过适当的测试,运行composer infection
以测试您的代码。
贡献
请随时通过发送Github pull请求为此库做出贡献。我非常积极哦 :-)