$violet = new State('violet');
// create the machine with the correct session adapter to store the state accross page refreshes
$adapter = new Session();
$machine = new StateMachine(new Context(new Identifier('session-example', 'rainbow-machine'), null, $adapter));
//add the transitions, going from one color to the next and back to the first
$machine->addTransition(new Transition($new, $red));
$machine->addTransition(new Transition($red, $orange));
$machine->addTransition(new Transition($orange, $yellow));
$machine->addTransition(new Transition($yellow, $green));
$machine->addTransition(new Transition($green, $blue));
$machine->addTransition(new Transition($blue, $indigo));
$machine->addTransition(new Transition($indigo, $violet));
$machine->addTransition(new Transition($violet, $red));
//initialize the first time to 'red' and then cycle through the
//colors for each page refresh
$machine->run();
//get some data to put in the output
$current = $machine->getCurrentState();
$next_transitions = implode(',', $current->getTransitions());
$next = $current->getTransitions()[0]->getStateTo();
//generate the ouput
$output = <<<EOT
<html>
<header>
<title>rainbows all over the place: gimme some more izzum jo!</title>
<style>
body {
background-color: {$current};
color: black;
padding:10px;
margin:10px;