@@ -71,7 +71,7 @@ |
||
71 | 71 | // |
72 | 72 | // we always search the generic 'Prose' namespace first, in case |
73 | 73 | // users don't want to uniquely namespace their Prose classes |
74 | - $this->namespaces = array ("Prose"); |
|
74 | + $this->namespaces = array("Prose"); |
|
75 | 75 | |
76 | 76 | // append the namespaces we've been asked to search |
77 | 77 | foreach ($namespaces as $namespace) { |
@@ -68,7 +68,7 @@ |
||
68 | 68 | // |
69 | 69 | // we always search the generic 'Reports' namespace first, in case |
70 | 70 | // users don't want to uniquely namespace their Report classes |
71 | - $this->namespaces = array ("Reports"); |
|
71 | + $this->namespaces = array("Reports"); |
|
72 | 72 | |
73 | 73 | // add in any additional namespaces we've been asked to search |
74 | 74 | foreach ($namespaces as $namespace) { |
@@ -58,143 +58,143 @@ |
||
58 | 58 | */ |
59 | 59 | class Story_Checkpoint implements IteratorAggregate |
60 | 60 | { |
61 | - /** |
|
62 | - * the StoryTeller object |
|
63 | - * |
|
64 | - * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
65 | - */ |
|
66 | - private $st; |
|
67 | - |
|
68 | - /** |
|
69 | - * keep track of whether the checkpoint is readonly (true) or |
|
70 | - * read-write(false) |
|
71 | - * |
|
72 | - * @var boolean |
|
73 | - */ |
|
74 | - private $readOnly = false; |
|
75 | - |
|
76 | - /** |
|
77 | - * the data stored inside the checkpoint |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - private $data = array(); |
|
82 | - |
|
83 | - /** |
|
84 | - * our constructor |
|
85 | - * |
|
86 | - * @param StoryTeller $st |
|
87 | - * The StoryTeller object (which we will cache) |
|
88 | - */ |
|
89 | - public function __construct(StoryTeller $st) |
|
90 | - { |
|
91 | - // remember the StoryTeller object for future use |
|
92 | - $this->st = $st; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * is the checkpoint currently readonly? |
|
97 | - * |
|
98 | - * @return boolean |
|
99 | - * TRUE if the checkpoint is currently readonly |
|
100 | - * FALSE if you can change the data in the checkpoint |
|
101 | - */ |
|
102 | - public function getReadOnly() |
|
103 | - { |
|
104 | - return $this->readOnly; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * put the checkpoint into readonly mode |
|
109 | - */ |
|
110 | - public function setReadOnly() |
|
111 | - { |
|
112 | - $this->readOnly = true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * put the checkpoint into read-write mode |
|
117 | - */ |
|
118 | - public function setReadWrite() |
|
119 | - { |
|
120 | - $this->readOnly = false; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * magic method to retrieve data from the checkpoint |
|
125 | - * |
|
126 | - * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
127 | - * to get data that does not exist |
|
128 | - * |
|
129 | - * @param string $key |
|
130 | - * the name of the data to store |
|
131 | - * @return mixed |
|
132 | - * the data stored in the checkpoint |
|
133 | - */ |
|
134 | - public function &__get($key) |
|
135 | - { |
|
136 | - // what are we doing? |
|
137 | - $log = usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
138 | - |
|
139 | - // do we have the data to return? |
|
140 | - if (!isset($this->data[$key])) { |
|
141 | - // no, we do not |
|
142 | - $log->endAction("'{$key}' is not in the checkpoint"); |
|
143 | - throw new E5xx_NoSuchDataInCheckpoint($key); |
|
144 | - } |
|
145 | - |
|
146 | - // yes, we do |
|
61 | + /** |
|
62 | + * the StoryTeller object |
|
63 | + * |
|
64 | + * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
65 | + */ |
|
66 | + private $st; |
|
67 | + |
|
68 | + /** |
|
69 | + * keep track of whether the checkpoint is readonly (true) or |
|
70 | + * read-write(false) |
|
71 | + * |
|
72 | + * @var boolean |
|
73 | + */ |
|
74 | + private $readOnly = false; |
|
75 | + |
|
76 | + /** |
|
77 | + * the data stored inside the checkpoint |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + private $data = array(); |
|
82 | + |
|
83 | + /** |
|
84 | + * our constructor |
|
85 | + * |
|
86 | + * @param StoryTeller $st |
|
87 | + * The StoryTeller object (which we will cache) |
|
88 | + */ |
|
89 | + public function __construct(StoryTeller $st) |
|
90 | + { |
|
91 | + // remember the StoryTeller object for future use |
|
92 | + $this->st = $st; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * is the checkpoint currently readonly? |
|
97 | + * |
|
98 | + * @return boolean |
|
99 | + * TRUE if the checkpoint is currently readonly |
|
100 | + * FALSE if you can change the data in the checkpoint |
|
101 | + */ |
|
102 | + public function getReadOnly() |
|
103 | + { |
|
104 | + return $this->readOnly; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * put the checkpoint into readonly mode |
|
109 | + */ |
|
110 | + public function setReadOnly() |
|
111 | + { |
|
112 | + $this->readOnly = true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * put the checkpoint into read-write mode |
|
117 | + */ |
|
118 | + public function setReadWrite() |
|
119 | + { |
|
120 | + $this->readOnly = false; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * magic method to retrieve data from the checkpoint |
|
125 | + * |
|
126 | + * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
127 | + * to get data that does not exist |
|
128 | + * |
|
129 | + * @param string $key |
|
130 | + * the name of the data to store |
|
131 | + * @return mixed |
|
132 | + * the data stored in the checkpoint |
|
133 | + */ |
|
134 | + public function &__get($key) |
|
135 | + { |
|
136 | + // what are we doing? |
|
137 | + $log = usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
138 | + |
|
139 | + // do we have the data to return? |
|
140 | + if (!isset($this->data[$key])) { |
|
141 | + // no, we do not |
|
142 | + $log->endAction("'{$key}' is not in the checkpoint"); |
|
143 | + throw new E5xx_NoSuchDataInCheckpoint($key); |
|
144 | + } |
|
145 | + |
|
146 | + // yes, we do |
|
147 | 147 | $log->endAction($this->data[$key]); |
148 | 148 | |
149 | - // all done |
|
150 | - return $this->data[$key]; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * magic method to tell if the data is stored in the checkpoint or not |
|
155 | - * |
|
156 | - * @param string $key |
|
157 | - * the name of the data to test for |
|
158 | - * @return boolean |
|
159 | - * TRUE if the data exists in the checkpoint |
|
160 | - * FALSE if the data does not exist in the checkpoint |
|
161 | - */ |
|
162 | - public function __isset($key) |
|
163 | - { |
|
164 | - return (isset($this->data[$key])); |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * magic method to store data in the checkpoint |
|
169 | - * |
|
170 | - * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
171 | - * to store data when the checkpoint is in readonly mode |
|
172 | - * |
|
173 | - * @param string $key |
|
174 | - * the name of the data to store |
|
175 | - * @param mixed $value |
|
176 | - * the value to store in the checkpoint |
|
177 | - * @return void |
|
178 | - */ |
|
179 | - public function __set($key, $value) |
|
180 | - { |
|
181 | - // what are we doing? |
|
182 | - $log = usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
183 | - |
|
184 | - // are we allowed to change the data at this time? |
|
185 | - if ($this->readOnly) |
|
186 | - { |
|
187 | - // no, we are not |
|
188 | - $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
189 | - throw new E5xx_CheckpointIsReadOnly(); |
|
190 | - } |
|
191 | - |
|
192 | - // if we get here, we're allowed to change the checkpoint |
|
193 | - $this->data[$key] = $value; |
|
194 | - |
|
195 | - // all done |
|
196 | - $log->endAction($value); |
|
197 | - } |
|
149 | + // all done |
|
150 | + return $this->data[$key]; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * magic method to tell if the data is stored in the checkpoint or not |
|
155 | + * |
|
156 | + * @param string $key |
|
157 | + * the name of the data to test for |
|
158 | + * @return boolean |
|
159 | + * TRUE if the data exists in the checkpoint |
|
160 | + * FALSE if the data does not exist in the checkpoint |
|
161 | + */ |
|
162 | + public function __isset($key) |
|
163 | + { |
|
164 | + return (isset($this->data[$key])); |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * magic method to store data in the checkpoint |
|
169 | + * |
|
170 | + * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
171 | + * to store data when the checkpoint is in readonly mode |
|
172 | + * |
|
173 | + * @param string $key |
|
174 | + * the name of the data to store |
|
175 | + * @param mixed $value |
|
176 | + * the value to store in the checkpoint |
|
177 | + * @return void |
|
178 | + */ |
|
179 | + public function __set($key, $value) |
|
180 | + { |
|
181 | + // what are we doing? |
|
182 | + $log = usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
183 | + |
|
184 | + // are we allowed to change the data at this time? |
|
185 | + if ($this->readOnly) |
|
186 | + { |
|
187 | + // no, we are not |
|
188 | + $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
189 | + throw new E5xx_CheckpointIsReadOnly(); |
|
190 | + } |
|
191 | + |
|
192 | + // if we get here, we're allowed to change the checkpoint |
|
193 | + $this->data[$key] = $value; |
|
194 | + |
|
195 | + // all done |
|
196 | + $log->endAction($value); |
|
197 | + } |
|
198 | 198 | |
199 | 199 | // ==================================================================== |
200 | 200 | // |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | $log = usingLog()->startAction("store '{$key}' in the checkpoint"); |
183 | 183 | |
184 | 184 | // are we allowed to change the data at this time? |
185 | - if ($this->readOnly) |
|
186 | - { |
|
185 | + if ($this->readOnly) { |
|
187 | 186 | // no, we are not |
188 | 187 | $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
189 | 188 | throw new E5xx_CheckpointIsReadOnly(); |
@@ -266,26 +265,22 @@ discard block |
||
266 | 265 | public function getList($propName) |
267 | 266 | { |
268 | 267 | // do we have the property at all? |
269 | - if (!isset($this->$propName)) |
|
270 | - { |
|
268 | + if (!isset($this->$propName)) { |
|
271 | 269 | // no ... send back an empty list |
272 | 270 | return array(); |
273 | 271 | } |
274 | 272 | |
275 | 273 | // is the property already a list? |
276 | - if (is_array($this->$propName)) |
|
277 | - { |
|
274 | + if (is_array($this->$propName)) { |
|
278 | 275 | // yes ... no conversion needed |
279 | 276 | return $this->$propName; |
280 | 277 | } |
281 | 278 | |
282 | 279 | // is the property something we can convert? |
283 | - if (is_object($this->$propName)) |
|
284 | - { |
|
280 | + if (is_object($this->$propName)) { |
|
285 | 281 | // yes |
286 | 282 | $return = array(); |
287 | - foreach ($this->$propName as $key => $value) |
|
288 | - { |
|
283 | + foreach ($this->$propName as $key => $value) { |
|
289 | 284 | $return[$key] = $value; |
290 | 285 | } |
291 | 286 | |
@@ -307,16 +302,14 @@ discard block |
||
307 | 302 | public function getString($propName, $default = '') |
308 | 303 | { |
309 | 304 | // does this property exist at all? |
310 | - if (!isset($this->$propName)) |
|
311 | - { |
|
305 | + if (!isset($this->$propName)) { |
|
312 | 306 | // no, so return the default |
313 | 307 | return $default; |
314 | 308 | } |
315 | 309 | |
316 | 310 | // is this property something that can be auto-converted to a |
317 | 311 | // string reliably? |
318 | - if (is_string($this->$propName) || is_int($this->$propName) || is_double($this->$propName)) |
|
319 | - { |
|
312 | + if (is_string($this->$propName) || is_int($this->$propName) || is_double($this->$propName)) { |
|
320 | 313 | // yes |
321 | 314 | return (string)$this->$propName; |
322 | 315 | } |
@@ -324,10 +317,8 @@ discard block |
||
324 | 317 | // starting to clutch at straws now |
325 | 318 | |
326 | 319 | // a boolean, perhaps? |
327 | - if (is_bool(($this->$propName))) |
|
328 | - { |
|
329 | - if ($this->$propName) |
|
330 | - { |
|
320 | + if (is_bool(($this->$propName))) { |
|
321 | + if ($this->$propName) { |
|
331 | 322 | return 'TRUE'; |
332 | 323 | } |
333 | 324 | |
@@ -335,11 +326,9 @@ discard block |
||
335 | 326 | } |
336 | 327 | |
337 | 328 | // is it an object that can convert itself to a string? |
338 | - if (is_object($this->$propName)) |
|
339 | - { |
|
329 | + if (is_object($this->$propName)) { |
|
340 | 330 | $refObj = new ReflectionObject($this->$propName); |
341 | - if ($refObj->hasMethod('__toString')) |
|
342 | - { |
|
331 | + if ($refObj->hasMethod('__toString')) { |
|
343 | 332 | return (string)$this->$propName; |
344 | 333 | } |
345 | 334 | |
@@ -367,14 +356,12 @@ discard block |
||
367 | 356 | $refProps = $refObj->getProperties(ReflectionProperty::IS_PUBLIC); |
368 | 357 | |
369 | 358 | // convert each property into an array entry |
370 | - foreach ($refProps as $refProp) |
|
371 | - { |
|
359 | + foreach ($refProps as $refProp) { |
|
372 | 360 | $propKey = $refProp->getName(); |
373 | 361 | $retKey = $propKey; |
374 | 362 | |
375 | 363 | // do we need to enforce the prefix? |
376 | - if ($prefix !== null && substr($this->$propKey, 0, strlen($prefix)) !== $prefix) |
|
377 | - { |
|
364 | + if ($prefix !== null && substr($this->$propKey, 0, strlen($prefix)) !== $prefix) { |
|
378 | 365 | // yes we do |
379 | 366 | $retKey = $prefix . $propKey; |
380 | 367 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * |
60 | 60 | * @var Story |
61 | 61 | */ |
62 | - public $story = null; |
|
62 | + public $story = null; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * is this a story where a failure is the expected outcome? |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | // we do not need to wrap these in a TRY/CATCH block, |
963 | 963 | // as we are already running inside one of the story's |
964 | 964 | // phases |
965 | - foreach ($callbacks as $callback){ |
|
965 | + foreach ($callbacks as $callback) { |
|
966 | 966 | call_user_func($callback, $this); |
967 | 967 | } |
968 | 968 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | // we do not need to wrap these in a TRY/CATCH block, |
1002 | 1002 | // as we are already running inside one of the story's |
1003 | 1003 | // phases |
1004 | - foreach ($callbacks as $callback){ |
|
1004 | + foreach ($callbacks as $callback) { |
|
1005 | 1005 | call_user_func($callback, $this); |
1006 | 1006 | } |
1007 | 1007 | } |
@@ -281,7 +281,8 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return Action_Logger |
283 | 283 | */ |
284 | - public function getActionLogger() { |
|
284 | + public function getActionLogger() |
|
285 | + { |
|
285 | 286 | return $this->actionLogger; |
286 | 287 | } |
287 | 288 | |
@@ -291,7 +292,8 @@ discard block |
||
291 | 292 | * @param Action_Logger $actionLogger |
292 | 293 | * @return StoryTeller |
293 | 294 | */ |
294 | - public function setActionLogger(Action_Logger $actionLogger) { |
|
295 | + public function setActionLogger(Action_Logger $actionLogger) |
|
296 | + { |
|
295 | 297 | $this->actionLogger = $actionLogger; |
296 | 298 | |
297 | 299 | return $this; |
@@ -302,7 +304,8 @@ discard block |
||
302 | 304 | * |
303 | 305 | * @return Story_Checkpoint |
304 | 306 | */ |
305 | - public function getCheckpoint() { |
|
307 | + public function getCheckpoint() |
|
308 | + { |
|
306 | 309 | return $this->checkpoint; |
307 | 310 | } |
308 | 311 | |
@@ -312,7 +315,8 @@ discard block |
||
312 | 315 | * @param Story_Checkpoint $checkpoint |
313 | 316 | * @return StoryTeller |
314 | 317 | */ |
315 | - public function setCheckpoint(Story_Checkpoint $checkpoint) { |
|
318 | + public function setCheckpoint(Story_Checkpoint $checkpoint) |
|
319 | + { |
|
316 | 320 | $this->checkpoint = $checkpoint; |
317 | 321 | |
318 | 322 | return $this; |
@@ -323,7 +327,8 @@ discard block |
||
323 | 327 | * |
324 | 328 | * @return PageContext |
325 | 329 | */ |
326 | - public function getPageContext() { |
|
330 | + public function getPageContext() |
|
331 | + { |
|
327 | 332 | return $this->pageContext; |
328 | 333 | } |
329 | 334 | |
@@ -333,7 +338,8 @@ discard block |
||
333 | 338 | * @param PageContext $pageContext |
334 | 339 | * @return StoryTeller |
335 | 340 | */ |
336 | - public function setPageContext(PageContext $pageContext) { |
|
341 | + public function setPageContext(PageContext $pageContext) |
|
342 | + { |
|
337 | 343 | $this->pageContext = $pageContext; |
338 | 344 | |
339 | 345 | return $this; |
@@ -393,7 +399,8 @@ discard block |
||
393 | 399 | * |
394 | 400 | * @return RuntimeConfigManager |
395 | 401 | */ |
396 | - public function getRuntimeConfigManager() { |
|
402 | + public function getRuntimeConfigManager() |
|
403 | + { |
|
397 | 404 | return $this->runtimeConfigManager; |
398 | 405 | } |
399 | 406 | |
@@ -403,7 +410,8 @@ discard block |
||
403 | 410 | * @param RuntimeConfigManager $runtimeConfigManager |
404 | 411 | * @return StoryTeller |
405 | 412 | */ |
406 | - public function setRuntimeConfigManager(RuntimeConfigManager $runtimeConfigManager) { |
|
413 | + public function setRuntimeConfigManager(RuntimeConfigManager $runtimeConfigManager) |
|
414 | + { |
|
407 | 415 | $this->runtimeConfigManager = $runtimeConfigManager; |
408 | 416 | |
409 | 417 | return $this; |
@@ -906,13 +914,11 @@ discard block |
||
906 | 914 | */ |
907 | 915 | public function getRunningDevice() |
908 | 916 | { |
909 | - if (!is_object($this->deviceAdapter)) |
|
910 | - { |
|
917 | + if (!is_object($this->deviceAdapter)) { |
|
911 | 918 | $this->startDevice(); |
912 | 919 | } |
913 | 920 | |
914 | - if (!is_object($this->deviceAdapter)) |
|
915 | - { |
|
921 | + if (!is_object($this->deviceAdapter)) { |
|
916 | 922 | throw new E5xx_CannotStartDevice(); |
917 | 923 | } |
918 | 924 | |
@@ -962,7 +968,7 @@ discard block |
||
962 | 968 | // we do not need to wrap these in a TRY/CATCH block, |
963 | 969 | // as we are already running inside one of the story's |
964 | 970 | // phases |
965 | - foreach ($callbacks as $callback){ |
|
971 | + foreach ($callbacks as $callback) { |
|
966 | 972 | call_user_func($callback, $this); |
967 | 973 | } |
968 | 974 | } |
@@ -1001,7 +1007,7 @@ discard block |
||
1001 | 1007 | // we do not need to wrap these in a TRY/CATCH block, |
1002 | 1008 | // as we are already running inside one of the story's |
1003 | 1009 | // phases |
1004 | - foreach ($callbacks as $callback){ |
|
1010 | + foreach ($callbacks as $callback) { |
|
1005 | 1011 | call_user_func($callback, $this); |
1006 | 1012 | } |
1007 | 1013 | } |
@@ -429,6 +429,7 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
432 | + * @param Prose_Loader $proseLoader |
|
432 | 433 | * @return void |
433 | 434 | */ |
434 | 435 | public function setProseLoader($proseLoader) |
@@ -445,6 +446,9 @@ discard block |
||
445 | 446 | return $this->phaseLoader; |
446 | 447 | } |
447 | 448 | |
449 | + /** |
|
450 | + * @param Phase_Loader $phaseLoader |
|
451 | + */ |
|
448 | 452 | public function setPhaseLoader($phaseLoader) |
449 | 453 | { |
450 | 454 | $this->phaseLoader = $phaseLoader; |
@@ -469,6 +473,9 @@ discard block |
||
469 | 473 | $this->output = $output; |
470 | 474 | } |
471 | 475 | |
476 | + /** |
|
477 | + * @param \DataSift\Storyplayer\OutputLib\DataFormatter $dataFormatter |
|
478 | + */ |
|
472 | 479 | public function setDataFormatter($dataFormatter) |
473 | 480 | { |
474 | 481 | $this->dataFormatter = $dataFormatter; |
@@ -501,6 +508,7 @@ discard block |
||
501 | 508 | } |
502 | 509 | |
503 | 510 | /** |
511 | + * @param \DataSift\Storyplayer\ConfigLib\ActiveConfig $config |
|
504 | 512 | * @return void |
505 | 513 | */ |
506 | 514 | public function setConfig($config) |
@@ -509,7 +517,7 @@ discard block |
||
509 | 517 | } |
510 | 518 | |
511 | 519 | /** |
512 | - * @return object |
|
520 | + * @return \DataSift\Storyplayer\TestEnvironmentsLib\TestEnvironmentRuntimeConfig |
|
513 | 521 | */ |
514 | 522 | public function getRuntimeConfig() |
515 | 523 | { |
@@ -517,6 +525,7 @@ discard block |
||
517 | 525 | } |
518 | 526 | |
519 | 527 | /** |
528 | + * @param \DataSift\Storyplayer\TestEnvironmentsLib\TestEnvironmentRuntimeConfig $runtimeConfig |
|
520 | 529 | * @return void |
521 | 530 | */ |
522 | 531 | public function setRuntimeConfig($runtimeConfig) |
@@ -764,7 +773,7 @@ discard block |
||
764 | 773 | * |
765 | 774 | * @param string $methodName |
766 | 775 | * @param array $methodArgs |
767 | - * @return mixed |
|
776 | + * @return \Prose\Prose |
|
768 | 777 | */ |
769 | 778 | public function __call($methodName, $methodArgs) |
770 | 779 | { |
@@ -58,70 +58,70 @@ |
||
58 | 58 | */ |
59 | 59 | class Tale_Loader |
60 | 60 | { |
61 | - /** |
|
62 | - * singleton - do not instantiate |
|
63 | - * @codeCoverageIgnore |
|
64 | - */ |
|
65 | - protected function __construct() |
|
66 | - { |
|
67 | - // do nothing |
|
68 | - } |
|
61 | + /** |
|
62 | + * singleton - do not instantiate |
|
63 | + * @codeCoverageIgnore |
|
64 | + */ |
|
65 | + protected function __construct() |
|
66 | + { |
|
67 | + // do nothing |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * load a story, throwing exceptions if problems are detected |
|
72 | - * |
|
73 | - * @param string $filename |
|
74 | - * path to the PHP file containing the story |
|
75 | - * @return Story |
|
76 | - * the story object |
|
77 | - */ |
|
78 | - static public function loadTale($filename) |
|
79 | - { |
|
80 | - if (!file_exists($filename)) { |
|
81 | - throw new E5xx_InvalidStoryListFile("Cannot find file '{$filename}' to load"); |
|
82 | - } |
|
70 | + /** |
|
71 | + * load a story, throwing exceptions if problems are detected |
|
72 | + * |
|
73 | + * @param string $filename |
|
74 | + * path to the PHP file containing the story |
|
75 | + * @return Story |
|
76 | + * the story object |
|
77 | + */ |
|
78 | + static public function loadTale($filename) |
|
79 | + { |
|
80 | + if (!file_exists($filename)) { |
|
81 | + throw new E5xx_InvalidStoryListFile("Cannot find file '{$filename}' to load"); |
|
82 | + } |
|
83 | 83 | |
84 | - // load the contents |
|
85 | - $contents = file_get_contents($filename); |
|
84 | + // load the contents |
|
85 | + $contents = file_get_contents($filename); |
|
86 | 86 | |
87 | - // does it decode? |
|
88 | - $tale = json_decode($contents); |
|
89 | - if (!$tale) { |
|
90 | - throw new E4xx_InvalidStoryListFile("Story list '{$filename}' does not contain valid JSON"); |
|
91 | - } |
|
87 | + // does it decode? |
|
88 | + $tale = json_decode($contents); |
|
89 | + if (!$tale) { |
|
90 | + throw new E4xx_InvalidStoryListFile("Story list '{$filename}' does not contain valid JSON"); |
|
91 | + } |
|
92 | 92 | |
93 | - // does it have the elements we require? |
|
94 | - if (!isset($tale->stories)) { |
|
95 | - throw new E4xx_InvalidStoryListFile("Story list '{$filename}' does not contain a 'stories' element"); |
|
96 | - } |
|
97 | - if (!is_array($tale->stories)) { |
|
98 | - throw new E4xx_InvalidStoryListFile("The 'stories' element in the story list '{$filename}' must be an array"); |
|
99 | - } |
|
100 | - if (count($tale->stories) == 0) { |
|
101 | - throw new E4xx_InvalidStoryListFile("The 'stories' element in the story list '{$filename}' cannot be an empty array"); |
|
102 | - } |
|
93 | + // does it have the elements we require? |
|
94 | + if (!isset($tale->stories)) { |
|
95 | + throw new E4xx_InvalidStoryListFile("Story list '{$filename}' does not contain a 'stories' element"); |
|
96 | + } |
|
97 | + if (!is_array($tale->stories)) { |
|
98 | + throw new E4xx_InvalidStoryListFile("The 'stories' element in the story list '{$filename}' must be an array"); |
|
99 | + } |
|
100 | + if (count($tale->stories) == 0) { |
|
101 | + throw new E4xx_InvalidStoryListFile("The 'stories' element in the story list '{$filename}' cannot be an empty array"); |
|
102 | + } |
|
103 | 103 | |
104 | - // our base directory to search from |
|
105 | - $storiesBasedir = dirname($filename); |
|
104 | + // our base directory to search from |
|
105 | + $storiesBasedir = dirname($filename); |
|
106 | 106 | |
107 | - // do all of the stories in the list exist? |
|
108 | - foreach ($tale->stories as $index => $storyFile) { |
|
109 | - $realStoryFile = $storiesBasedir . DIRECTORY_SEPARATOR . $storyFile; |
|
110 | - if (file_exists($realStoryFile)) { |
|
111 | - throw new E4xx_InvalidStoryListFile("Cannot find the story file '{$realStoryFile}' on disk"); |
|
112 | - } |
|
113 | - $tale->stories[$index] = $realStoryFile; |
|
114 | - } |
|
107 | + // do all of the stories in the list exist? |
|
108 | + foreach ($tale->stories as $index => $storyFile) { |
|
109 | + $realStoryFile = $storiesBasedir . DIRECTORY_SEPARATOR . $storyFile; |
|
110 | + if (file_exists($realStoryFile)) { |
|
111 | + throw new E4xx_InvalidStoryListFile("Cannot find the story file '{$realStoryFile}' on disk"); |
|
112 | + } |
|
113 | + $tale->stories[$index] = $realStoryFile; |
|
114 | + } |
|
115 | 115 | |
116 | - // inject defaults for optional fields |
|
117 | - if (!isset($tale->options)) { |
|
118 | - $tale->options = new stdClass(); |
|
119 | - } |
|
120 | - if (!isset($tale->options->reuseTestEnvironment)) { |
|
121 | - $tale->options->reuseTestEnvironment = false; |
|
122 | - } |
|
116 | + // inject defaults for optional fields |
|
117 | + if (!isset($tale->options)) { |
|
118 | + $tale->options = new stdClass(); |
|
119 | + } |
|
120 | + if (!isset($tale->options->reuseTestEnvironment)) { |
|
121 | + $tale->options->reuseTestEnvironment = false; |
|
122 | + } |
|
123 | 123 | |
124 | - // all done |
|
125 | - return $tale; |
|
126 | - } |
|
124 | + // all done |
|
125 | + return $tale; |
|
126 | + } |
|
127 | 127 | } |
128 | 128 | \ No newline at end of file |
@@ -103,8 +103,7 @@ |
||
103 | 103 | |
104 | 104 | // now we need to play whatever runs against this |
105 | 105 | // test environment |
106 | - foreach ($this->wrappedPlayers as $wrappedPlayer) |
|
107 | - { |
|
106 | + foreach ($this->wrappedPlayers as $wrappedPlayer) { |
|
108 | 107 | // play the wrapped item |
109 | 108 | // |
110 | 109 | // this is normally a story |
@@ -175,8 +175,8 @@ |
||
175 | 175 | |
176 | 176 | // build the command for Ansible |
177 | 177 | $command = 'ansible-playbook -i "' . $inventoryFile . '"' |
178 | - . ' "--private-key=' . $sshKeyFile . '"' |
|
179 | - . ' "--user=' . $sshUsername . '"'; |
|
178 | + . ' "--private-key=' . $sshKeyFile . '"' |
|
179 | + . ' "--user=' . $sshUsername . '"'; |
|
180 | 180 | |
181 | 181 | $command .= ' "' . $ansibleSettings->dir . DIRECTORY_SEPARATOR . $ansibleSettings->playbook . '"'; |
182 | 182 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if (isset($machine->params)) { |
87 | 87 | $params = []; |
88 | 88 | foreach ($machine->params as $paramName => $paramValue) { |
89 | - $params[$paramName] = fromConfig()->get('hosts.' . $hostId . '.params.'.$paramName); |
|
89 | + $params[$paramName] = fromConfig()->get('hosts.' . $hostId . '.params.' . $paramName); |
|
90 | 90 | } |
91 | 91 | if (count($params)) { |
92 | 92 | usingProvisioningDefinition($provDef)->addParams($params)->toHost($hostId); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $rolesToHosts = array(); |
112 | 112 | |
113 | 113 | // build up the list of roles |
114 | - foreach($hosts as $hostId => $hostProps) { |
|
114 | + foreach ($hosts as $hostId => $hostProps) { |
|
115 | 115 | // what is the host's IP address? |
116 | 116 | $ipAddress = fromHost($hostId)->getIpAddress(); |
117 | 117 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $sshKeyFile = null; |
155 | 155 | |
156 | 156 | // now we need to write out the host files |
157 | - foreach($hosts as $hostId => $hostProps) { |
|
157 | + foreach ($hosts as $hostId => $hostProps) { |
|
158 | 158 | // what is the host's IP address? |
159 | 159 | $ipAddress = fromHost($hostId)->getIpAddress(); |
160 | 160 | $sshUsername = fromHost($hostId)->getSshUsername(); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | // does the target folder exist? |
237 | 237 | $hostVarsFolder = dirname($filename); |
238 | 238 | if (!file_exists($hostVarsFolder)) { |
239 | - mkdir ($hostVarsFolder); |
|
239 | + mkdir($hostVarsFolder); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // write the data |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (isset($machine->params)) { |
89 | 89 | $params = []; |
90 | 90 | foreach ($machine->params as $paramName => $paramValue) { |
91 | - $params[$paramName] = fromConfig()->get('hosts.' . $hostId . '.params.'.$paramName); |
|
91 | + $params[$paramName] = fromConfig()->get('hosts.' . $hostId . '.params.' . $paramName); |
|
92 | 92 | } |
93 | 93 | if (count($params)) { |
94 | 94 | usingProvisioningDefinition($provDef)->addParams($params)->toHost($hostId); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $dsbuildParams = new BaseObject; |
111 | 111 | |
112 | 112 | // build up the list of settings to write out |
113 | - foreach($hosts as $hostId => $hostProps) { |
|
113 | + foreach ($hosts as $hostId => $hostProps) { |
|
114 | 114 | // what is the host's IP address? |
115 | 115 | $ipAddress = fromHost($hostId)->getIpAddress(); |
116 | 116 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | // at this point, we are ready to attempt provisioning |
133 | 133 | // |
134 | 134 | // provision each host in the order that they're listed |
135 | - foreach($hosts as $hostId => $hostProps) { |
|
135 | + foreach ($hosts as $hostId => $hostProps) { |
|
136 | 136 | // which dsbuildfile are we going to run? |
137 | 137 | $hostDir = fromHost($hostId)->getLocalFolder(); |
138 | 138 | $dsbuildFilename = $this->getDsbuildFilename($hostDir, $provConfig, $hostId); |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | // copy the dsbuildparams files to the target machine using scp |
149 | 149 | // NOTE: the "vagrant rsync" command seems not working with some Vagrant provisioners (e.g. OpenStack) |
150 | 150 | $command = 'scp' |
151 | - .' '.$dsbuildParams->{'hosts_'.$hostId.'_scpOptions_0'} |
|
152 | - .' '.$dsbuildParams->{'hosts_'.$hostId.'_scpOptions_1'} |
|
151 | + .' ' . $dsbuildParams->{'hosts_' . $hostId . '_scpOptions_0'} |
|
152 | + .' ' . $dsbuildParams->{'hosts_' . $hostId . '_scpOptions_1'} |
|
153 | 153 | .' dsbuildparams.*' |
154 | - .' '.$dsbuildParams->{'hosts_'.$hostId.'_sshUsername'} |
|
155 | - .'@'.$dsbuildParams->{'hosts_'.$hostId.'_ipAddress'} |
|
154 | + .' ' . $dsbuildParams->{'hosts_' . $hostId . '_sshUsername'} |
|
155 | + .'@' . $dsbuildParams->{'hosts_' . $hostId . '_ipAddress'} |
|
156 | 156 | .':/vagrant/'; |
157 | 157 | $result = $commandRunner->runSilently($command); |
158 | 158 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return array |
230 | 230 | * the flattened data |
231 | 231 | */ |
232 | - protected function flattenData($inputData, $prefix="") |
|
232 | + protected function flattenData($inputData, $prefix = "") |
|
233 | 233 | { |
234 | 234 | $retval = []; |
235 | 235 |
@@ -233,8 +233,7 @@ |
||
233 | 233 | { |
234 | 234 | $retval = []; |
235 | 235 | |
236 | - foreach ($inputData as $name => $dataToFlatten) |
|
237 | - { |
|
236 | + foreach ($inputData as $name => $dataToFlatten) { |
|
238 | 237 | if (is_object($dataToFlatten) || is_array($dataToFlatten)) { |
239 | 238 | $retval = array_merge($retval, $this->flattenData($dataToFlatten, $prefix . $name . "_")); |
240 | 239 | } |