PHP code example of aegisora / scalar-equality-rule

1. Go to this page and download the library: Download aegisora/scalar-equality-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 / scalar-equality-rule example snippets


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

$result = ScalarEqualityRule::createEqual(42)->validate(Context::create(42));

if ($result->isValid()) {
    // values are equal
} else {
    // values are NOT equal
}

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

$result = ScalarEqualityRule::createNotEqual(42)->validate(Context::create(100));

if ($result->isValid()) {
    // values are NOT equal (as expected)
} else {
    // values are equal (unexpected)
}

ScalarEqualityRule::createEqual($expectedValue);
ScalarEqualityRule::createNotEqual($expectedValue);

Aegisora\RuleContract\Exceptions\InvalidRuleContextException