PHP implementation of the Specification pattern
$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();
}
- PHP 5.3+
Specification is licensed under the MIT License - see the LICENSE
file for details