fragoe/ddd-business-rules-specification

Core library implementing the Specification Pattern for DDD business rules with composable boolean operations.

Maintainers

Package info

github.com/fragoe/ddd-business-rules-specification

pkg:composer/fragoe/ddd-business-rules-specification

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-01-05 20:44 UTC

This package is auto-updated.

Last update: 2026-04-05 21:14:30 UTC


README

Tests codecov PHP Version License

A lightweight PHP library implementing the Specification Pattern for Domain-Driven Design. Compose business rules with a fluent API using and(), or(), not(), and xor().

Installation

composer require fragoe/ddd-business-rules-specification

Requirements: PHP ^8.3

Usage

Extend CompositeBusinessRule and implement isSatisfiedBy(). Compose rules using the fluent API.

See tests/CompositeBusinessRulesTest.php for comprehensive usage examples including rule creation, composition, and fluent chaining. For a real-world domain example, see tests/CoffeeExamplesTest.php.

Built-in Composites

Class Description
AndBusinessRule All rules must be satisfied
OrBusinessRule At least one rule must be satisfied
XorBusinessRule Exactly one rule must be satisfied
NotBusinessRule Inverts the rule result

Design Philosophy

This library follows strict DDD principles and intentionally excludes infrastructure concerns. Database queries, visualization, and validation framework integration are handled by companion packages:

Package Ecosystem

Package Description
fragoe/ddd-business-rules Meta package
fragoe/ddd-business-rules-specification Core library (this package)
fragoe/ddd-business-rules-doctrine Doctrine bridge
fragoe/ddd-business-rules-validation Validation integration
fragoe/ddd-business-rules-analyzer Analysis tools

License

MIT - See LICENSE