Added Specification pattern

This commit is contained in:
martin
2013-11-24 22:30:06 +00:00
parent 1e76d98540
commit 6edac3f229
9 changed files with 384 additions and 0 deletions

34
Specification/Not.php Executable file
View File

@@ -0,0 +1,34 @@
<?php
namespace DesignPatterns\Specification;
/**
* A logical Not specification
*/
class Not extends AbstractSpecification
{
protected $spec;
/**
* Creates a new specification wrapping another
*
* @param SpecificationInterface $spec
*/
public function __construct(SpecificationInterface $spec)
{
$this->spec = $spec;
}
/**
* Returns the negated result of the wrapped specification
*
* @param Item $item
*
* @return bool
*/
public function isSatisfiedBy(Item $item)
{
return !$this->spec->isSatisfiedBy($item);
}
}