1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author stev leibelt <[email protected]> |
4
|
|
|
* @since 2013-06-26 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Example\Table; |
8
|
|
|
|
9
|
|
|
use Example\Table\Items\BrownColor; |
10
|
|
|
use Example\Table\Items\ExtendableFeature; |
11
|
|
|
use Example\Table\Items\FoldableFeature; |
12
|
|
|
use Example\Table\Items\GreenColor; |
13
|
|
|
use Example\Table\Items\JensWieseDeveloper; |
14
|
|
|
use Example\Table\Items\PerfectHeight; |
15
|
|
|
use Example\Table\Items\RedColor; |
16
|
|
|
use Example\Table\Items\StevLeibeltDeveloper; |
17
|
|
|
use Example\Table\Items\YellowColor; |
18
|
|
|
use Net\Bazzline\Component\Requirement\AndCondition; |
19
|
|
|
use Net\Bazzline\Component\Requirement\OrCondition; |
20
|
|
|
use Net\Bazzline\Component\Requirement\Requirement; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class IsAGoodTableRequirement |
24
|
|
|
* |
25
|
|
|
* @method IsAGoodTableRequirement setColor($color) Sets the color (string) |
26
|
|
|
* @method IsAGoodTableRequirement setDeveloper($developer) Sets the developer (string) |
27
|
|
|
* @method IsAGoodTableRequirement setFeature($feature) Sets the feature (string) |
28
|
|
|
* @method IsAGoodTableRequirement setHeight($height) Sets the height (string) |
29
|
|
|
* |
30
|
|
|
* @package Example\Table |
31
|
|
|
* @author stev leibelt <[email protected]> |
32
|
|
|
* @since 2013-06-26 |
33
|
|
|
*/ |
34
|
|
|
class IsAGoodTableRequirement extends Requirement |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* This requirement is testing against following properties |
38
|
|
|
* [[green|red|brown|yellow]&[extendable|foldable]&[80cm]]or[jens wiese|stevleibelt] |
39
|
|
|
* |
40
|
|
|
* @author stev leibelt <[email protected]> |
41
|
|
|
* @since 2013-06-26 |
42
|
|
|
*/ |
43
|
|
|
public function __construct() |
44
|
|
|
{ |
45
|
|
|
parent::__construct(); |
46
|
|
|
$colorCondition = $this->createColorCondition(); |
47
|
|
|
$featureCondition = $this->createFeatureCondition(); |
48
|
|
|
$perfectHeight = new PerfectHeight(); |
49
|
|
|
$developerCondition = $this->createDeveloperCondition(); |
50
|
|
|
|
51
|
|
|
$andCondition = new AndCondition(); |
52
|
|
|
$andCondition->addItem($colorCondition); |
53
|
|
|
$andCondition->addItem($featureCondition); |
54
|
|
|
$andCondition->addItem($perfectHeight); |
55
|
|
|
|
56
|
|
|
$orCondition = new OrCondition(); |
57
|
|
|
$orCondition->addItem($developerCondition); |
58
|
|
|
$orCondition->addItem($andCondition); |
59
|
|
|
|
60
|
|
|
$this->addCondition($orCondition); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $color |
65
|
|
|
* @param string $developer |
66
|
|
|
* @param string $feature |
67
|
|
|
* @param string $height |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function __invoke($color, $developer, $feature, $height) |
71
|
|
|
{ |
72
|
|
|
$this->setColor($color); |
73
|
|
|
$this->setDeveloper($developer); |
74
|
|
|
$this->setFeature($feature); |
75
|
|
|
$this->setHeight($height); |
76
|
|
|
|
77
|
|
|
return $this->isMet(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return OrCondition |
82
|
|
|
* @author stev leibelt <[email protected]> |
83
|
|
|
* @since 2013-06-26 |
84
|
|
|
*/ |
85
|
|
|
private function createColorCondition() |
86
|
|
|
{ |
87
|
|
|
$brown = new BrownColor(); |
88
|
|
|
$green = new GreenColor(); |
89
|
|
|
$red = new RedColor(); |
90
|
|
|
$yellow = new YellowColor(); |
91
|
|
|
|
92
|
|
|
$condition = new OrCondition(); |
93
|
|
|
$condition->addItem($brown); |
94
|
|
|
$condition->addItem($green); |
95
|
|
|
$condition->addItem($red); |
96
|
|
|
$condition->addItem($yellow); |
97
|
|
|
|
98
|
|
|
return $condition; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return OrCondition |
103
|
|
|
* @author stev leibelt <[email protected]> |
104
|
|
|
* @since 2013-06-26 |
105
|
|
|
*/ |
106
|
|
|
private function createFeatureCondition() |
107
|
|
|
{ |
108
|
|
|
$extendable = new ExtendableFeature(); |
109
|
|
|
$foldable = new FoldableFeature(); |
110
|
|
|
|
111
|
|
|
$condition = new OrCondition(); |
112
|
|
|
$condition->addItem($extendable); |
113
|
|
|
$condition->addItem($foldable); |
114
|
|
|
|
115
|
|
|
return $condition; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return OrCondition |
120
|
|
|
* @author stev leibelt <[email protected]> |
121
|
|
|
* @since 2013-06-26 |
122
|
|
|
*/ |
123
|
|
|
private function createDeveloperCondition() |
124
|
|
|
{ |
125
|
|
|
$condition = new OrCondition(); |
126
|
|
|
$condition->addItem(new JensWieseDeveloper()); |
127
|
|
|
$condition->addItem(new StevLeibeltDeveloper()); |
128
|
|
|
|
129
|
|
|
return $condition; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|