Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/texdc/guard
assertion library with reusable guard function
https://github.com/texdc/guard
assert guard php71
Last synced: about 19 hours ago
JSON representation
assertion library with reusable guard function
- Host: GitHub
- URL: https://github.com/texdc/guard
- Owner: texdc
- License: mit
- Created: 2017-10-17T05:40:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-17T05:58:01.000Z (over 7 years ago)
- Last Synced: 2024-11-18T23:58:23.269Z (2 months ago)
- Topics: assert, guard, php71
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# guard
An extension for [beberlei/assert](https://github.com/beberlei/assert) that adds some
extra assertions and a factory function to simplify usage.## installation
```sh
composer require texdc/guard
```## usage
```php
namespace my\lib;use function texdc\guard\verify;
function storeRating(int $rating) : void {
verify($rating)->numericRange(1, 10, 'rating should be from 1 - 10');
// ...
}function speak(string $message, ?int $times = null) : void {
verify($message)->notEmpty('message is required')->length(256, 'message is too long');
verify($times, 'invalid multiplier')->nullOr()->isModulus(8);
// ...
}
```