rikbruil/specification

A PHP implementation of the Specification-pattern

Installs: 263 959

Dependents: 1

Suggesters: 0

Security: 0

Stars: 18

Watchers: 3

Forks: 3

Open Issues: 0

pkg:composer/rikbruil/specification

0.9.4 2015-03-12 21:26 UTC

This package is not auto-updated.

Last update: 2025-09-27 22:43:42 UTC


README

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 5.3+

License

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