fragoe / php-specifications
Specification pattern by Eric Evans and Martin Fowler (2002, "Specifications", martinfowler.com/apsupp/spec.pdf).
v0.1.0
2026-04-12 15:10 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.0 || ^11.0 || ^12.0 || ^13.0
README
A PHP implementation of the Specification pattern by Eric Evans and Martin Fowler (2002).
Specifications are business rules represented as predicates.
Composable specifications can be combined using logical operators (and, or, xor, not).
Requirements
- PHP ^8.1
Installation
composer require fragoe/php-specifications
Usage
Use Specification when you only need a simple predicate with one method (isSatisfiedBy()).
Use ComposableSpecification for fluent composition methods (and(), or(), xor(), not()).
In most cases, extend AbstractComposableSpecification to get those methods by default.
See the tests for practical examples.
Contributing
See CONTRIBUTING.md for compatibility policy details.
License
MIT