function ExtensionSet::getTest
File
-
vendor/
twig/ twig/ src/ ExtensionSet.php, line 366
Class
- ExtensionSet
- @author Fabien Potencier <fabien@symfony.com>
Namespace
TwigCode
public function getTest(string $name) : ?TwigTest {
if (!$this->initialized) {
$this->initExtensions();
}
if (isset($this->tests[$name])) {
return $this->tests[$name];
}
foreach ($this->dynamicTests as $pattern => $test) {
if (preg_match($pattern, $name, $matches)) {
array_shift($matches);
return $test->withDynamicArguments($name, $test->getName(), $matches);
}
}
return null;
}