Download the PHP package larapie/guard without Composer
On this page you can find all versions of the php package larapie/guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download larapie/guard
More information about larapie/guard
Files in larapie/guard
Package guard
Short Description Guard objects for conditional exception throwing.
License MIT
Homepage https://github.com/larapie/guard
Informations about the package guard
Guard
Installation
You can install the package via composer:
Have you ever…
… encountered a situation where you had countless if statements that needed to throw specific errors when conditions were met?
Here's an example:
The goal of this package is to decouple these conditions and their exceptions in a guard object. This guard object can then be handled by the GuardHandler. By structuring this code in a guard object, we gain several advantages:
- We're able to reuse the same conditions in the code elsewhere.
- The code becomes a lot easier to read.
- More fine grained control of what exceptions will be thrown.
Let's rewrite the example from above with guards:
Note that the order of the guards will determine what exception will be thrown first.
Future
- Implement a feature that allows the guard handler to handle OR statements.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Anthony Vancauwenberghe
- All Contributors
License
The MIT License (MIT). Please see License File for more information.