bytic / assert
Bytic assert component
Installs: 213
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/bytic/assert
Requires
- php: ^7.4|^8.0
- bytic/package-base: ^1.0
- webmozart/assert: ^1.10
Requires (Dev)
- bytic/phpqatools: ^1.0
- phpbench/phpbench: ^1.2
README
Validating data and throwing exceptions is a great way to make your code more robust. It comes in handy especially in domain logic objects like Actions or Commands.
Why another assertion library
There are two great and very used PHP assertion libraries:
- [beberlei/assert]
- [webmozart/assert]
What we hope to achive with this implementation is to provide:
- chained assertions (we really like the Pest expectations approach)
- a fluent way to provide optional arguments (messages, code etc.)
- provide custom exception classes
Usage
Assert::that($var) ->isNumeric() ->equals(5) ->orFail("Not Numeric") ->throw(MyCustomException::class);