rikbruil/specification

PHP实现的Specification模式

0.9.4 2015-03-12 21:26 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:31:54 UTC


README

Build Status Coverage Status Latest Stable Version License SensioLabsInsight

PHP实现的Specification模式

用法

$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遵循MIT许可证 - 请参阅LICENSE文件以获取详细信息