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

View File

@@ -0,0 +1,53 @@
<?php
namespace DesignPatterns\Specification;
/**
* An abstract specification allows the creation of wrapped specifications
*/
abstract class AbstractSpecification implements SpecificationInterface
{
/**
* Checks if given item meets all criteria
*
* @param Item $item
*
* @return bool
*/
public function isSatisfiedBy(Item $item)
{
}
/**
* Creates a new logical AND specification
*
* @param SpecificationInterface $spec
*
* @return SpecificationInterface
*/
public function plus(SpecificationInterface $spec)
{
return new Plus($this, $spec);
}
/**
* Creates a new logical OR composite specification
*
* @param SpecificationInterface $spec
*
* @return SpecificationInterface
*/
public function either(SpecificationInterface $spec)
{
return new Either($this, $spec);
}
/**
* Creates a new logical NOT specification
*
* @return SpecificationInterface
*/
public function not()
{
return new Not($this);
}
}