Skip to content

Implementation of the specification pattern in PHP

License

Notifications You must be signed in to change notification settings

PuristPHP/specification

 
 

Repository files navigation

Specification

Build Status Coverage Status Latest Stable Version License SensioLabsInsight

PHP implementation of the Specification pattern

Usage

$overDue        = new OverDueSpecification();
$noticeSent     = new NoticeSentSpecification();
$inCollection   = new InCollectionSpecification();

// example of specification pattern logic chaining
$sendToCollection = $overDue->andX($noticeSent)
                            ->not($inCollection);

foreach ($service->getInvoices() as $currentInvoice) {
    if (! $sendToCollection->isSatisfiedBy($currentInvoice)) {
        continue;
    }

    $currentInvoice->sendToCollection();
}

Requirements

  • PHP 8.2+

License

Specification is licensed under the MIT License - see the LICENSE file for details

About

Implementation of the specification pattern in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%