States.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. //require 'Yay/SelfDescribing.php';
  15. /**
  16. * A basic state machine.
  17. * @author Chris Corbyn <chris@w3style.co.uk>
  18. * @package Yay
  19. */
  20. interface Yay_States extends Yay_SelfDescribing
  21. {
  22. /**
  23. * Set the initial state of this state machine.
  24. * @param string $stateName
  25. * @return Yay_States
  26. */
  27. public function startsAs($stateName);
  28. /**
  29. * Get the state which puts the state machine into the named state.
  30. * @param string $stateName
  31. * @return Yay_State
  32. */
  33. public function is($stateName);
  34. /**
  35. * Get the predicate which indicates the state machine is NOT in the named state.
  36. * @param string $stateName
  37. * @return Yay_StatePredicate
  38. */
  39. public function isNot($stateName);
  40. /**
  41. * Become the named state.
  42. * @param string $stateName
  43. */
  44. public function become($stateName);
  45. /**
  46. * Get the name of the current state.
  47. * @return string
  48. */
  49. public function getCurrentState();
  50. }