mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 17:04:01 +02:00
start a restructure
This commit is contained in:
37
Behavioral/Specification/Plus.php
Normal file
37
Behavioral/Specification/Plus.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace DesignPatterns\Specification;
|
||||
|
||||
/**
|
||||
* A logical AND specification
|
||||
*/
|
||||
class Plus extends AbstractSpecification
|
||||
{
|
||||
|
||||
protected $left;
|
||||
protected $right;
|
||||
|
||||
/**
|
||||
* Creation of a locical AND of two specifications
|
||||
*
|
||||
* @param SpecificationInterface $left
|
||||
* @param SpecificationInterface $right
|
||||
|
||||
*/
|
||||
public function __construct(SpecificationInterface $left, SpecificationInterface $right)
|
||||
{
|
||||
$this->left = $left;
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the composite AND of specifications passes
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item)
|
||||
{
|
||||
return $this->left->isSatisfiedBy($item) && $this->right->isSatisfiedBy($item);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user