@@ 12-63 (lines=52) @@ | ||
9 | * |
|
10 | * @author gbprod <[email protected]> |
|
11 | */ |
|
12 | final class AndX extends CompositeSpecification |
|
13 | { |
|
14 | /** |
|
15 | * @var Specification |
|
16 | */ |
|
17 | private $firstPart; |
|
18 | ||
19 | /** |
|
20 | * @var Specification |
|
21 | */ |
|
22 | private $secondPart; |
|
23 | ||
24 | /** |
|
25 | * @param Specification $firstPart |
|
26 | * @param Specification $secondPart |
|
27 | */ |
|
28 | public function __construct(Specification $firstPart, Specification $secondPart) |
|
29 | { |
|
30 | $this->firstPart = $firstPart; |
|
31 | $this->secondPart = $secondPart; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * {inheritdoc} |
|
36 | */ |
|
37 | public function isSatisfiedBy($candidate): bool |
|
38 | { |
|
39 | return $this->firstPart->isSatisfiedBy($candidate) |
|
40 | && $this->secondPart->isSatisfiedBy($candidate) |
|
41 | ; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Get the first part of the condition |
|
46 | * |
|
47 | * @return Specification |
|
48 | */ |
|
49 | public function getFirstPart(): Specification |
|
50 | { |
|
51 | return $this->firstPart; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Get the second part of the condition |
|
56 | * |
|
57 | * @return Specification |
|
58 | */ |
|
59 | public function getSecondPart(): Specification |
|
60 | { |
|
61 | return $this->secondPart; |
|
62 | } |
|
63 | } |
|
64 |
@@ 12-63 (lines=52) @@ | ||
9 | * |
|
10 | * @author gbprod <[email protected]> |
|
11 | */ |
|
12 | final class OrX extends CompositeSpecification |
|
13 | { |
|
14 | /** |
|
15 | * @var Specification |
|
16 | */ |
|
17 | private $firstPart; |
|
18 | ||
19 | /** |
|
20 | * @var Specification |
|
21 | */ |
|
22 | private $secondPart; |
|
23 | ||
24 | /** |
|
25 | * @param Specification $firstPart |
|
26 | * @param Specification $secondPart |
|
27 | */ |
|
28 | public function __construct(Specification $firstPart, Specification $secondPart) |
|
29 | { |
|
30 | $this->firstPart = $firstPart; |
|
31 | $this->secondPart = $secondPart; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * {inheritdoc} |
|
36 | */ |
|
37 | public function isSatisfiedBy($candidate): bool |
|
38 | { |
|
39 | return $this->firstPart->isSatisfiedBy($candidate) |
|
40 | || $this->secondPart->isSatisfiedBy($candidate) |
|
41 | ; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Get the first part of the condition |
|
46 | * |
|
47 | * @return Specification |
|
48 | */ |
|
49 | public function getFirstPart(): Specification |
|
50 | { |
|
51 | return $this->firstPart; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Get the second part of the condition |
|
56 | * |
|
57 | * @return Specification |
|
58 | */ |
|
59 | public function getSecondPart(): Specification |
|
60 | { |
|
61 | return $this->secondPart; |
|
62 | } |
|
63 | } |
|
64 |