37 lines
805 B
PHP
Raw Normal View History

2013-11-24 22:30:06 +00:00
<?php
namespace DesignPatterns\Specification;
/**
* A logical AND specification
*/
class Either extends AbstractSpecification
{
protected $left;
protected $right;
/**
* A composite wrapper of two specifications
*
* @param SpecificationInterface $left
* @param SpecificationInterface $right
*/
public function __construct(SpecificationInterface $left, SpecificationInterface $right)
{
$this->left = $left;
$this->right = $right;
}
/**
* Returns the evaluation of both wrapped specifications as a logical AND
*
* @param Item $item
*
* @return bool
*/
public function isSatisfiedBy(Item $item)
{
return $this->left->isSatisfiedBy($item) || $this->right->isSatisfiedBy($item);
}
}