. */ declare(strict_types=1); namespace FireflyIII\TransactionRules\Expressions; use Symfony\Component\ExpressionLanguage\ExpressionFunction; use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInterface { public function getFunctions(): array { return [ new ExpressionFunction( 'constant', function ($str): string { return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'!'); }, // @SuppressWarnings(PHPMD.UnusedFormalParameter) function ($arguments, $str): string { if (!is_string($str)) { return (string) $str; } return strtolower($str.'!'); } ), new ExpressionFunction( 'enum', function ($str): string { return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str.'?'); }, // @SuppressWarnings(PHPMD.UnusedFormalParameter) function ($arguments, $str): string { if (!is_string($str)) { return (string) $str; } return strtolower($str).'?'; } ), ExpressionFunction::fromPhp('substr'), ExpressionFunction::fromPhp('strlen'), ]; } }