PHP code example of subzeta / ruling
1. Go to this page and download the library: Download subzeta/ruling 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/ */
subzeta / ruling example snippets
use subzeta\Ruling\Ruling;
$my = new \stdClass();
$my->sensitivity = 80;
$my->joyfulness = 10;
(new Ruling())
->given([
'sensitivity' => $my->sensitivity,
'joyfulness' => $my->joyfulness
])->when(
':sensitivity is greater than 90 or :joyfulness is less than 20'
)->then(function() {
echo 'Hell yeah, I should listen music right now!';
})->otherwise(function() {
echo 'I\'m happy enough, thanks.';
})->execute();
// Outputs: Hell yeah, I should listen music right now!