Installation
tilttek/dice-jailRequirements
- PHP 8.5 or later, with
mbstring. tilttek/dice0.2 or 0.3, whose rolled dice a tally reads, andtilttek/dice-probability0.1, whose exact distributions give the faces of a fair die.- An implementation of
psr/clock, such assymfony/clock.
Installing
composer require tilttek/dice-jail
Wiring the library
use Symfony\Component\Clock\NativeClock;
use Tilttek\DiceJail\Jail\Warden;
use Tilttek\DiceJail\Statistics\DieAssessor;
use Tilttek\DiceJail\Statistics\Explanation;
use Tilttek\DiceJail\Statistics\GoodnessOfFit;
$warden = new Warden($jailStore, new NativeClock()); // Contract\JailStore: the history of each die
$assessor = new DieAssessor($rollSource); // Contract\RollSource: the rolls of each die
$test = new GoodnessOfFit();
$explanation = new Explanation();
None keeps state between two calls, so one instance serves every request of a worker. Store\InMemoryJailStore and
Store\InMemoryRollSource keep everything in the process, for tests and scripts; their reset() empties them.