Version 1.x
Introduction
Version 1 was written to replace ganbarodigital/php-defensive
. It offers pretty much the same functionality as that library did, just with an improved interface.
Key Ideas
The key ideas in Version 1 are:
- requirements (checks on inputs) and assurances (checks on outputs and return values)
Assurance::apply()->to()
/Requirement::apply()->to()
pattern - apply the assurance / requirement to a value. If the assurance / requirement isn't met, throw an exception.ListAssurance::apply()->toList()
/ListRequirement::apply()->toList()
pattern - apply the assurance / requirement to a list of values. If the assurance / requirement isn't met, throw an exception.- composable assurances and requirements - each
Assurance
/Requirement
now takes one parameter (the value being checked). This allows us to build lists of assurances / requirements to apply to a value.
Components
Version 1 ships with the following components:
Namespace | Purpose |
---|---|
GanbaroDigital\Defensive\V1\Assurances |
robustness checks for outputs and return values |
GanbaroDigital\Defensive\V1\Exceptions |
exceptions thrown by this library |
GanbaroDigital\Defensive\V1\Interfaces |
interfaces defined by this library |
GanbaroDigital\Defensive\V1\Requirements |
robustness checks for inputs |
Click on the namespace to learn more about the classes in that component.