woodpecker-email/src/Pipeline/Evaluation.php
Simon Vieille 65f4049c28
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
refactor all by using PHP instead of Golang
2024-01-15 12:38:30 +01:00

22 lines
465 B
PHP

<?php
namespace Plugin\Pipeline;
use Twig\Environment;
class Evaluation
{
public function __construct(protected Environment $twig)
{
}
public function isTrue(string $rule, array $data)
{
$rule = str_replace(['{{', '}}'], '', $rule);
$rule = sprintf('{{ (%s) is same as (true) ? "true" : "false" }}', $rule);
$template = $this->twig->createTemplate($rule);
return 'true' === $template->render($data);
}
}