mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-23 17:22:41 +01:00
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
namespace DesignPatterns\Behavioral\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
|
|
*/
|
|
abstract 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);
|
|
}
|
|
}
|