@@ -61,7 +61,8 @@ |
||
61 | 61 | /** |
62 | 62 | * @param string $key |
63 | 63 | */ |
64 | - public function __construct($key) { |
|
64 | + public function __construct($key) |
|
65 | + { |
|
65 | 66 | $msg = "No such data '{$key}' in the checkpoint"; |
66 | 67 | parent::__construct(500, $msg, $msg); |
67 | 68 | } |
@@ -61,7 +61,8 @@ |
||
61 | 61 | /** |
62 | 62 | * @param string $className |
63 | 63 | */ |
64 | - public function __construct($className) { |
|
64 | + public function __construct($className) |
|
65 | + { |
|
65 | 66 | $msg = "Class '{$className}' does not inherit from Prose\\Prose"; |
66 | 67 | parent::__construct(500, $msg, $msg); |
67 | 68 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | // |
69 | 69 | // we always search the generic 'Phases' namespace first, in case |
70 | 70 | // users don't want to uniquely namespace their Phase classes |
71 | - $this->namespaces = array ("Phases"); |
|
71 | + $this->namespaces = array("Phases"); |
|
72 | 72 | |
73 | 73 | // add in any additional namespaces we've been asked to search |
74 | 74 | foreach ($namespaces as $namespace) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function playPhases($activity, StoryTeller $st, Injectables $injectables, $phases, $thingBeingPlayed) |
79 | 79 | { |
80 | 80 | // shorthand |
81 | - $output = $st->getOutput(); |
|
81 | + $output = $st->getOutput(); |
|
82 | 82 | |
83 | 83 | // we are going to need something to help us load each of our |
84 | 84 | // phases |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | // the result of playing this group of phases |
100 | 100 | $groupResult = null; |
101 | - if ($thingBeingPlayed){ |
|
101 | + if ($thingBeingPlayed) { |
|
102 | 102 | $groupResult = $thingBeingPlayed->getResult(); |
103 | 103 | $groupResult->setActivity($activity); |
104 | 104 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | // the result of playing this group of phases |
100 | 100 | $groupResult = null; |
101 | - if ($thingBeingPlayed){ |
|
101 | + if ($thingBeingPlayed) { |
|
102 | 102 | $groupResult = $thingBeingPlayed->getResult(); |
103 | 103 | $groupResult->setActivity($activity); |
104 | 104 | } |
@@ -110,8 +110,7 @@ discard block |
||
110 | 110 | // |
111 | 111 | // 1. all listed phases have been executed, or |
112 | 112 | // 2. one of the phases says that the story has failed |
113 | - foreach ($phasesToPlay as $phaseName => $phaseData) |
|
114 | - { |
|
113 | + foreach ($phasesToPlay as $phaseName => $phaseData) { |
|
115 | 114 | // shorthand |
116 | 115 | $phase = $phaseData['phase']; |
117 | 116 | $isActive = $phaseData['isActive']; |
@@ -128,8 +127,7 @@ discard block |
||
128 | 127 | |
129 | 128 | // now, what do we do? |
130 | 129 | $nextAction = $phaseResult->getNextAction(); |
131 | - switch ($nextAction) |
|
132 | - { |
|
130 | + switch ($nextAction) { |
|
133 | 131 | case self::NEXT_SKIP: |
134 | 132 | // why? |
135 | 133 | if ($phaseResult->getPhaseIsBlacklisted()) { |
@@ -78,37 +78,37 @@ |
||
78 | 78 | * |
79 | 79 | * @var PhaseResult |
80 | 80 | */ |
81 | - public $failedPhase = null; |
|
81 | + public $failedPhase = null; |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * did the story pass, fail, or otherwise go horribly wrong? |
85 | 85 | * @var integer |
86 | 86 | */ |
87 | - public $resultCode = 0; |
|
87 | + public $resultCode = 0; |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * when did we start playing this story? |
91 | 91 | * @var float |
92 | 92 | */ |
93 | - public $startTime = null; |
|
93 | + public $startTime = null; |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * when did we finish playing this story? |
97 | 97 | * @var float |
98 | 98 | */ |
99 | - public $endTime = null; |
|
99 | + public $endTime = null; |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * how long did the story take to play? |
103 | 103 | * @var float |
104 | 104 | */ |
105 | - public $durationTime = null; |
|
105 | + public $durationTime = null; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * which file is this PhaseGroup_Result associated with? |
109 | 109 | * @var string |
110 | 110 | */ |
111 | - public $filename = null; |
|
111 | + public $filename = null; |
|
112 | 112 | |
113 | 113 | const UNKNOWN = 0; |
114 | 114 | const OKAY = 1; |
@@ -223,8 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function getPhaseGroupFailed() |
225 | 225 | { |
226 | - switch ($this->resultCode) |
|
227 | - { |
|
226 | + switch ($this->resultCode) { |
|
228 | 227 | case self::FAIL: |
229 | 228 | case self::ERROR: |
230 | 229 | case self::INCOMPLETE: |
@@ -240,8 +239,7 @@ discard block |
||
240 | 239 | */ |
241 | 240 | public function getPhaseGroupSkipped() |
242 | 241 | { |
243 | - switch ($this->resultCode) |
|
244 | - { |
|
242 | + switch ($this->resultCode) { |
|
245 | 243 | case self::BLACKLISTED: |
246 | 244 | case self::SKIPPED: |
247 | 245 | return true; |
@@ -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) { |
@@ -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,143 +59,143 @@ |
||
59 | 59 | */ |
60 | 60 | class Story_Checkpoint implements IteratorAggregate |
61 | 61 | { |
62 | - /** |
|
63 | - * the StoryTeller object |
|
64 | - * |
|
65 | - * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
66 | - */ |
|
67 | - private $st; |
|
68 | - |
|
69 | - /** |
|
70 | - * keep track of whether the checkpoint is readonly (true) or |
|
71 | - * read-write(false) |
|
72 | - * |
|
73 | - * @var boolean |
|
74 | - */ |
|
75 | - private $readOnly = false; |
|
76 | - |
|
77 | - /** |
|
78 | - * the data stored inside the checkpoint |
|
79 | - * |
|
80 | - * @var array |
|
81 | - */ |
|
82 | - private $data = array(); |
|
83 | - |
|
84 | - /** |
|
85 | - * our constructor |
|
86 | - * |
|
87 | - * @param StoryTeller $st |
|
88 | - * The StoryTeller object (which we will cache) |
|
89 | - */ |
|
90 | - public function __construct(StoryTeller $st) |
|
91 | - { |
|
92 | - // remember the StoryTeller object for future use |
|
93 | - $this->st = $st; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * is the checkpoint currently readonly? |
|
98 | - * |
|
99 | - * @return boolean |
|
100 | - * TRUE if the checkpoint is currently readonly |
|
101 | - * FALSE if you can change the data in the checkpoint |
|
102 | - */ |
|
103 | - public function getReadOnly() |
|
104 | - { |
|
105 | - return $this->readOnly; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * put the checkpoint into readonly mode |
|
110 | - */ |
|
111 | - public function setReadOnly() |
|
112 | - { |
|
113 | - $this->readOnly = true; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * put the checkpoint into read-write mode |
|
118 | - */ |
|
119 | - public function setReadWrite() |
|
120 | - { |
|
121 | - $this->readOnly = false; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * magic method to retrieve data from the checkpoint |
|
126 | - * |
|
127 | - * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
128 | - * to get data that does not exist |
|
129 | - * |
|
130 | - * @param string $key |
|
131 | - * the name of the data to store |
|
132 | - * @return mixed |
|
133 | - * the data stored in the checkpoint |
|
134 | - */ |
|
135 | - public function &__get($key) |
|
136 | - { |
|
137 | - // what are we doing? |
|
138 | - $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
139 | - |
|
140 | - // do we have the data to return? |
|
141 | - if (!isset($this->data[$key])) { |
|
142 | - // no, we do not |
|
143 | - $log->endAction("'{$key}' is not in the checkpoint"); |
|
144 | - throw new E5xx_NoSuchDataInCheckpoint($key); |
|
145 | - } |
|
146 | - |
|
147 | - // yes, we do |
|
62 | + /** |
|
63 | + * the StoryTeller object |
|
64 | + * |
|
65 | + * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
66 | + */ |
|
67 | + private $st; |
|
68 | + |
|
69 | + /** |
|
70 | + * keep track of whether the checkpoint is readonly (true) or |
|
71 | + * read-write(false) |
|
72 | + * |
|
73 | + * @var boolean |
|
74 | + */ |
|
75 | + private $readOnly = false; |
|
76 | + |
|
77 | + /** |
|
78 | + * the data stored inside the checkpoint |
|
79 | + * |
|
80 | + * @var array |
|
81 | + */ |
|
82 | + private $data = array(); |
|
83 | + |
|
84 | + /** |
|
85 | + * our constructor |
|
86 | + * |
|
87 | + * @param StoryTeller $st |
|
88 | + * The StoryTeller object (which we will cache) |
|
89 | + */ |
|
90 | + public function __construct(StoryTeller $st) |
|
91 | + { |
|
92 | + // remember the StoryTeller object for future use |
|
93 | + $this->st = $st; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * is the checkpoint currently readonly? |
|
98 | + * |
|
99 | + * @return boolean |
|
100 | + * TRUE if the checkpoint is currently readonly |
|
101 | + * FALSE if you can change the data in the checkpoint |
|
102 | + */ |
|
103 | + public function getReadOnly() |
|
104 | + { |
|
105 | + return $this->readOnly; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * put the checkpoint into readonly mode |
|
110 | + */ |
|
111 | + public function setReadOnly() |
|
112 | + { |
|
113 | + $this->readOnly = true; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * put the checkpoint into read-write mode |
|
118 | + */ |
|
119 | + public function setReadWrite() |
|
120 | + { |
|
121 | + $this->readOnly = false; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * magic method to retrieve data from the checkpoint |
|
126 | + * |
|
127 | + * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
128 | + * to get data that does not exist |
|
129 | + * |
|
130 | + * @param string $key |
|
131 | + * the name of the data to store |
|
132 | + * @return mixed |
|
133 | + * the data stored in the checkpoint |
|
134 | + */ |
|
135 | + public function &__get($key) |
|
136 | + { |
|
137 | + // what are we doing? |
|
138 | + $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
139 | + |
|
140 | + // do we have the data to return? |
|
141 | + if (!isset($this->data[$key])) { |
|
142 | + // no, we do not |
|
143 | + $log->endAction("'{$key}' is not in the checkpoint"); |
|
144 | + throw new E5xx_NoSuchDataInCheckpoint($key); |
|
145 | + } |
|
146 | + |
|
147 | + // yes, we do |
|
148 | 148 | $log->endAction($this->data[$key]); |
149 | 149 | |
150 | - // all done |
|
151 | - return $this->data[$key]; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * magic method to tell if the data is stored in the checkpoint or not |
|
156 | - * |
|
157 | - * @param string $key |
|
158 | - * the name of the data to test for |
|
159 | - * @return boolean |
|
160 | - * TRUE if the data exists in the checkpoint |
|
161 | - * FALSE if the data does not exist in the checkpoint |
|
162 | - */ |
|
163 | - public function __isset($key) |
|
164 | - { |
|
165 | - return (isset($this->data[$key])); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * magic method to store data in the checkpoint |
|
170 | - * |
|
171 | - * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
172 | - * to store data when the checkpoint is in readonly mode |
|
173 | - * |
|
174 | - * @param string $key |
|
175 | - * the name of the data to store |
|
176 | - * @param mixed $value |
|
177 | - * the value to store in the checkpoint |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - public function __set($key, $value) |
|
181 | - { |
|
182 | - // what are we doing? |
|
183 | - $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
184 | - |
|
185 | - // are we allowed to change the data at this time? |
|
186 | - if ($this->readOnly) |
|
187 | - { |
|
188 | - // no, we are not |
|
189 | - $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
190 | - throw new E5xx_CheckpointIsReadOnly(); |
|
191 | - } |
|
192 | - |
|
193 | - // if we get here, we're allowed to change the checkpoint |
|
194 | - $this->data[$key] = $value; |
|
195 | - |
|
196 | - // all done |
|
197 | - $log->endAction($value); |
|
198 | - } |
|
150 | + // all done |
|
151 | + return $this->data[$key]; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * magic method to tell if the data is stored in the checkpoint or not |
|
156 | + * |
|
157 | + * @param string $key |
|
158 | + * the name of the data to test for |
|
159 | + * @return boolean |
|
160 | + * TRUE if the data exists in the checkpoint |
|
161 | + * FALSE if the data does not exist in the checkpoint |
|
162 | + */ |
|
163 | + public function __isset($key) |
|
164 | + { |
|
165 | + return (isset($this->data[$key])); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * magic method to store data in the checkpoint |
|
170 | + * |
|
171 | + * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
172 | + * to store data when the checkpoint is in readonly mode |
|
173 | + * |
|
174 | + * @param string $key |
|
175 | + * the name of the data to store |
|
176 | + * @param mixed $value |
|
177 | + * the value to store in the checkpoint |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + public function __set($key, $value) |
|
181 | + { |
|
182 | + // what are we doing? |
|
183 | + $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
184 | + |
|
185 | + // are we allowed to change the data at this time? |
|
186 | + if ($this->readOnly) |
|
187 | + { |
|
188 | + // no, we are not |
|
189 | + $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
190 | + throw new E5xx_CheckpointIsReadOnly(); |
|
191 | + } |
|
192 | + |
|
193 | + // if we get here, we're allowed to change the checkpoint |
|
194 | + $this->data[$key] = $value; |
|
195 | + |
|
196 | + // all done |
|
197 | + $log->endAction($value); |
|
198 | + } |
|
199 | 199 | |
200 | 200 | // ==================================================================== |
201 | 201 | // |
@@ -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? |