PHP code example of kmuenkel / rule-evaluator

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

    

kmuenkel / rule-evaluator example snippets


return [
    'isKevin' => [
        'reference1' => 'name.first',
        'comparator' => '==',
        'value2' => 'Kevin'
    ],
    'inCarolinas' => [
        'reference1' => 'address.state',
        'comparator => 'in',
        'value2' => [
            'NC',
            'SC'
        ]
    ],
    'isMe' => [
        'comparator' => 'all',
        'value2' => [
            'isKevin',
            'inCarolinas
        ]
    ]
];

use Evaluator\Parsers\ConfigParser;

$rules = son"), true);
$data = array_dot($data);

$ result = (new ConfigParser($data, $rules))->evaluate('isMe'); // true