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