@@ -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) { |
@@ -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? |