mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
37 lines
805 B
PHP
37 lines
805 B
PHP
|
<?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);
|
||
|
}
|
||
|
}
|