| 1 | <?php |
||
| 15 | class StateStack |
||
| 16 | { |
||
| 17 | protected $stack; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Constructor. Starts in named state. |
||
| 21 | * @param string $start Starting state name. |
||
| 22 | */ |
||
| 23 | public function __construct($start) |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Accessor for current state. |
||
| 30 | * @return string State. |
||
| 31 | */ |
||
| 32 | public function getCurrent() |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Adds a state to the stack and sets it to be the current state. |
||
| 39 | * |
||
| 40 | * @param string $state New state. |
||
| 41 | */ |
||
| 42 | public function enter($state) |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Leaves the current state and reverts |
||
| 49 | * to the previous one. |
||
| 50 | * @return boolean False if we drop off the bottom of the list. |
||
| 51 | */ |
||
| 52 | public function leave() |
||
| 60 | } |
||
| 61 |