| @@ 8-38 (lines=31) @@ | ||
| 5 | use Alchemy\Pipeline\Specification; |
|
| 6 | use Alchemy\Resource\Resource; |
|
| 7 | ||
| 8 | class AndSpecification implements Specification |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Specification |
|
| 12 | */ |
|
| 13 | private $lhs; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var Specification |
|
| 17 | */ |
|
| 18 | private $rhs; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @param Specification $lhs |
|
| 22 | * @param Specification $rhs |
|
| 23 | */ |
|
| 24 | public function __construct(Specification $lhs, Specification $rhs) |
|
| 25 | { |
|
| 26 | $this->lhs = $lhs; |
|
| 27 | $this->rhs = $rhs; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @param \Alchemy\Resource\Resource $resource |
|
| 32 | * @return bool |
|
| 33 | */ |
|
| 34 | public function isSatisfiedBy(Resource $resource) |
|
| 35 | { |
|
| 36 | return $this->lhs->isSatisfiedBy($resource) && $this->rhs->isSatisfiedBy($resource); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 8-39 (lines=32) @@ | ||
| 5 | use Alchemy\Pipeline\Specification; |
|
| 6 | use Alchemy\Resource\Resource; |
|
| 7 | ||
| 8 | class OrSpecification implements Specification |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Specification |
|
| 12 | */ |
|
| 13 | private $lhs; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var Specification |
|
| 17 | */ |
|
| 18 | private $rhs; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @param Specification $lhs |
|
| 22 | * @param Specification $rhs |
|
| 23 | */ |
|
| 24 | public function __construct(Specification $lhs, Specification $rhs) |
|
| 25 | { |
|
| 26 | ||
| 27 | $this->lhs = $lhs; |
|
| 28 | $this->rhs = $rhs; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param \Alchemy\Resource\Resource $resource |
|
| 33 | * @return bool |
|
| 34 | */ |
|
| 35 | public function isSatisfiedBy(Resource $resource) |
|
| 36 | { |
|
| 37 | return $this->lhs->isSatisfiedBy($resource) || $this->rhs->isSatisfiedBy($resource); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||