1. Go to this page and download the library: Download jeroen-g/statinator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use JeroenG\Statinator\Statinator;
$statinator = new Statinator($config);
use JeroenG\Statinator\StatableInterface;
class LightSwitch implements StatableInterface {
private string $currentState;
public function __construct(string $initialState)
{
$this->currentState = $initialState;
}
public function getState(): string
{
return $this->currentState;
}
public function setState(string $to): void
{
$this->currentState = $to;
}
}
use JeroenG\Statinator\ActionableInterface;
use JeroenG\Statinator\StateMachineInterface;
class NotifyLightsAreOn implements ActionableInterface {
private StateMachineInterface $stateMachine;
private string $transition;
public function getState(): string
{
return $this->stateMachine->getState();
}
public function execute(StateMachineInterface $stateMachine, string $transition): void
{
$this->stateMachine = $stateMachine;
$this->transition = $transition;
$notifier = new MyNotifier();
$notifier->send('Lights are turned on');
}
public function getTransition(): string
{
return $this->transition;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.