37 lines
814 B
PHP
Raw Normal View History

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