Skip to content

Support for custom objects

Compare
Choose a tag to compare
@nicoSWD nicoSWD released this 13 Jun 08:50
· 21 commits to master since this release
a023a94

This release adds the ability to call methods on objects, and use the result as part of the rule.

class User
{
    // ...

    public function points(): int
    {
        return 1337;    
    }
}

$variables = [
    'user' => new User(),
];

$rule = new Rule('user.points() > 300', $variables);
var_dump($rule->isTrue()); // bool(true)