123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
-
-
-
-
-
-
-
-
-
- class Yay_StateMachine implements Yay_States
- {
-
-
-
- private $_name;
-
-
-
- private $_state;
-
-
-
- public function __construct($name)
- {
- $this->_name = $name;
- }
-
-
-
- public function startsAs($stateName)
- {
- $this->become($stateName);
- return $this;
- }
-
-
-
- public function is($stateName)
- {
- return new Yay_SimpleState($this, $stateName);
- }
-
-
-
- public function isNot($stateName)
- {
- return new Yay_SimpleStatePredicate($this, $stateName, false);
- }
-
-
-
- public function become($stateName)
- {
- $this->_state = $stateName;
- }
-
-
-
- public function getCurrentState()
- {
- return $this->_state;
- }
-
-
-
- public function describeTo(Yay_Description $description)
- {
- $description->appendText(sprintf(' %s', $this->_name));
- }
-
- }
|