1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
-
-
-
-
-
-
-
- class Yay_SimpleStatePredicate implements Yay_StatePredicate
- {
-
-
-
- protected $_stateMachine;
-
-
-
- protected $_stateName;
-
-
-
- private $_is = true;
-
-
-
- public function __construct(Yay_States $stateMachine, $stateName, $is = true)
- {
- $this->_stateMachine = $stateMachine;
- $this->_stateName = $stateName;
- $this->_is = $is;
- }
-
-
-
- public function isActive()
- {
- return (($this->_is && $this->_stateMachine->getCurrentState() == $this->_stateName)
- || (!$this->_is && $this->_stateMachine->getCurrentState() != $this->_stateName));
- }
-
-
-
- public function describeTo(Yay_Description $description)
- {
- $this->_stateMachine->describeTo($description);
- $description->appendText(sprintf(
- ' %s %s;',
- ($this->_is ? 'is' : 'is not'),
- $this->_stateName
- ));
- }
-
- }
|