Skip to content

Commit 8e96312

Browse files
committed
replace preg_match by a custom expression
1 parent 3d4efae commit 8e96312

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/TestPattern.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
namespace Kiboko\Component\StringExpressionLanguage;
66

7-
class TestPattern
7+
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
8+
9+
class TestPattern extends ExpressionFunction
810
{
911
public function __construct($name)
1012
{
13+
parent::__construct(
14+
$name,
15+
$this->compile(...)->bindTo($this),
16+
$this->evaluate(...)->bindTo($this)
17+
);
1118
}
1219

13-
private function compile(string $pattern, string $subject): bool
20+
private function compile(string $pattern, string $subject): string
1421
{
1522
return <<<PHP
1623
\$result = preg_match({$pattern}, {$subject});

0 commit comments

Comments
 (0)