We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to add a new function to use each function in my custom code
each
The text was updated successfully, but these errors were encountered:
Can you show me an example on how this would look like in your code?
What are you planning to do with this?
Sorry, something went wrong.
I was looking to add a modulo function, basically [variable] % 10 == 0.
[variable] % 10 == 0
But I see you allow class to be set as variables.
class User { // ... public function points(): int { return 1337; } } $variables = [ 'user' => new User(), ];
Hey @jalite1991
you have two options. If you're using Symfony, there's a bundle with native support for custom functions.
The other option is to use a custom class and pass it as variable
<?php $math = new class { public function mod($x, $y) { return $x % $y; } }; $rule = new Rule('math.mod(13, 3) === 1', ['math' => $math]); var_dump($rule->isTrue()); // bool(true)
I hope this helps!
No branches or pull requests
I'm trying to add a new function to use
each
function in my custom codeThe text was updated successfully, but these errors were encountered: