https://github.com/texdc/guard
assertion library with reusable guard function
https://github.com/texdc/guard
assert guard php71
Last synced: 5 months 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 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-17T05:58:01.000Z (over 8 years ago)
- Last Synced: 2025-08-13T23:59:21.412Z (10 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);
// ...
}
```