drupol / valuewrapper
This library allows you to wrap any kind of PHP variable in a strict typed PHP object.
Fund package maintenance!
drupol
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
Description
This library allows you to wrap PHP variable in a strict typed PHP object.
Documentation
TODO.
Requirements
- PHP >= 7.1
Installation
composer require drupol/valuewrapper
Usage
$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.
Code quality and tests
Every time changes are introduced into the library, Github run the tests.
The library has tests written with PHPSpec.
Feel free to check them out in the spec
directory. Run composer phpspec
to trigger the tests.
PHPInfection is used to ensure that your code is properly tested, run composer infection
to test your code.
Contributing
Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)