jobcloud / jobcloud-closure-validator
This package is abandoned and no longer maintained.
No replacement package was suggested.
Jobcloud Closure Validator
3.0.0
2018-06-11 14:47 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is not auto-updated.
Last update: 2022-01-14 22:48:08 UTC
README
Features
A simple validator to check closure signatures.
Requirements
PHP ~7.0
Installation
Through Composer as jobcloud/jobcloud-closure-validator.
Usage
Prepare
use Jobcloud\ClosureValidator\Parameter;
use Jobcloud\ClosureValidator\Signature;
use Jobcloud\ClosureValidator\Validator;
$closure = function($param1, $param2) {};
$validator = new Validator;
$givenSignature = $validator->getSignatureFromClosure($closure);
$wishedSignature = new Signature(
[
new Parameter('param1'),
new Parameter('param2')
]
);
Diff
$diff = $validator->compare($givenSignature, $wishedSignature);
if (!$diff->isIdentical()) {
throw new \Exception('Invalid closure signature');
}
Valid or exception
$validator->validOrException($givenSignature, $wishedSignature);