1 | <?php |
||
10 | final class InMemoryRules implements Rules |
||
11 | { |
||
12 | /** |
||
13 | * @var Rule[] |
||
14 | */ |
||
15 | private $rules = []; |
||
16 | |||
17 | /** |
||
18 | * @inheritdoc |
||
19 | * |
||
20 | * @param Rule $rule |
||
21 | * |
||
22 | * @return $this |
||
23 | */ |
||
24 | 2 | public function addRule(Rule $rule) |
|
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | * |
||
36 | * @param Rule $rule |
||
37 | * |
||
38 | * @return $this |
||
39 | */ |
||
40 | 2 | public function removeRule(Rule $rule) |
|
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | * |
||
54 | * @param Task $task |
||
55 | * @param Profile $profile |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 2 | public function canRunTask(Task $task, Profile $profile) |
|
79 | |||
80 | /** |
||
81 | * Gets all the rules that apply to a task. |
||
82 | * |
||
83 | * @param Task $task |
||
84 | * |
||
85 | * @return Rule[] |
||
86 | */ |
||
87 | private function getRulesForTask(Task $task) |
||
93 | |||
94 | /** |
||
95 | * Checks whether there are too many processes running to start a new one. |
||
96 | * |
||
97 | * @param Rule $rule |
||
98 | * @param Profile $profile |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | 2 | private function hasTooManyProcessesRunning(Rule $rule, Profile $profile) |
|
106 | |||
107 | /** |
||
108 | * Checks whether the current profile is within the constraints of a rule. |
||
109 | * |
||
110 | * @param Rule $rule |
||
111 | * @param Profile $profile |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | 2 | private function withinConstraints(Rule $rule, Profile $profile) |
|
119 | |||
120 | /** |
||
121 | * Checks whether the current profile is within the processor constraints of a rule. |
||
122 | * |
||
123 | * @param Rule $rule |
||
124 | * @param Profile $profile |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | 2 | private function withinProcessorConstraints(Rule $rule, Profile $profile) |
|
136 | |||
137 | /** |
||
138 | * Checks whether the current profile is within the memory constraints of a rule. |
||
139 | * |
||
140 | * @param Rule $rule |
||
141 | * @param Profile $profile |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | 1 | private function withinMemoryConstraints(Rule $rule, Profile $profile) |
|
153 | |||
154 | /** |
||
155 | * Checks whether there are too many sibling processes running to start a new one. |
||
156 | * |
||
157 | * @param Rule $rule |
||
158 | * @param Profile $profile |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | 2 | private function hasTooManySiblingProcessesRunning(Rule $rule, Profile $profile) |
|
166 | |||
167 | /** |
||
168 | * Checks whether the profile or sibling processes is within the constraints of a rule. |
||
169 | * |
||
170 | * @param Rule $rule |
||
171 | * @param Profile $profile |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | 2 | private function withinSiblingConstraints(Rule $rule, Profile $profile) |
|
179 | |||
180 | /** |
||
181 | * Checks whether the profile or sibling processes is within the processor constraints of a |
||
182 | * rule. |
||
183 | * |
||
184 | * @param Rule $rule |
||
185 | * @param Profile $profile |
||
186 | * |
||
187 | * @return bool |
||
188 | */ |
||
189 | 2 | private function withinSiblingProcessorConstraints(Rule $rule, Profile $profile) |
|
197 | |||
198 | /** |
||
199 | * Checks whether the profile or sibling processes is within the memory constraints of a rule. |
||
200 | * |
||
201 | * @param Rule $rule |
||
202 | * @param Profile $profile |
||
203 | * |
||
204 | * @return bool |
||
205 | */ |
||
206 | 2 | private function withinSiblingMemoryConstraints(Rule $rule, Profile $profile) |
|
214 | } |
||
215 |