@@ 8-39 (lines=32) @@ | ||
5 | /** |
|
6 | * And specification |
|
7 | */ |
|
8 | class AndSpecification extends CompositeSpecification |
|
9 | { |
|
10 | /** |
|
11 | * @var SpecificationInterface One specification |
|
12 | */ |
|
13 | private $one; |
|
14 | ||
15 | /** |
|
16 | * @var SpecificationInterface Other specification |
|
17 | */ |
|
18 | private $other; |
|
19 | ||
20 | /** |
|
21 | * Constructor |
|
22 | * |
|
23 | * @param SpecificationInterface $one |
|
24 | * @param SpecificationInterface $other |
|
25 | */ |
|
26 | public function __construct(SpecificationInterface $one, SpecificationInterface $other) |
|
27 | { |
|
28 | $this->one = $one; |
|
29 | $this->other = $other; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * {@inheritdoc} |
|
34 | */ |
|
35 | public function isSatisfiedBy($object) |
|
36 | { |
|
37 | return $this->one->isSatisfiedBy($object) && $this->other->isSatisfiedBy($object); |
|
38 | } |
|
39 | } |
@@ 8-39 (lines=32) @@ | ||
5 | /** |
|
6 | * Or specification |
|
7 | */ |
|
8 | class OrSpecification extends CompositeSpecification |
|
9 | { |
|
10 | /** |
|
11 | * @var SpecificationInterface One specification |
|
12 | */ |
|
13 | private $one; |
|
14 | ||
15 | /** |
|
16 | * @var SpecificationInterface Other specification |
|
17 | */ |
|
18 | private $other; |
|
19 | ||
20 | /** |
|
21 | * Constructor |
|
22 | * |
|
23 | * @param SpecificationInterface $one |
|
24 | * @param SpecificationInterface $other |
|
25 | */ |
|
26 | public function __construct(SpecificationInterface $one, SpecificationInterface $other) |
|
27 | { |
|
28 | $this->one = $one; |
|
29 | $this->other = $other; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * {@inheritdoc} |
|
34 | */ |
|
35 | public function isSatisfiedBy($object) |
|
36 | { |
|
37 | return $this->one->isSatisfiedBy($object) || $this->other->isSatisfiedBy($object); |
|
38 | } |
|
39 | } |