drupol/valuewrapper

此库允许您将任何类型的PHP变量包装在严格的PHP对象中。

资助包维护!
drupol

1.2.0 2019-07-09 07:29 UTC

This package is auto-updated.

Last update: 2022-10-28 17:13:48 UTC


README

Latest Stable Version GitHub stars Total Downloads GitHub Workflow Status Scrutinizer code quality Code Coverage Mutation testing badge License Say Thanks! Donate!

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请求为此库做出贡献。我非常积极哦 :-)