PHP code example of aegisora / boolean-rule

1. Go to this page and download the library: Download aegisora/boolean-rule 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/ */

    

aegisora / boolean-rule example snippets


use Aegisora\Rules\BooleanRule;
use Aegisora\RuleContract\Models\Context;

$result = BooleanRule::createTruthy()->validate(Context::create(true));

if ($result->isValid()) {
    // value is true (as expected)
} else {
    // value is not true
}

use Aegisora\Rules\BooleanRule;
use Aegisora\RuleContract\Models\Context;

$result = BooleanRule::createFalsy()->validate(Context::create(false));

if ($result->isValid()) {
    // value is false (as expected)
} else {
    // value is not false
}

BooleanRule::createTruthy();
BooleanRule::createFalsy();