protected function getMatcher($matcherIdentifier)
{
// Not a FQ class name, so take the relative namespace.
if ($matcherIdentifier[0] !== '\\' && $this->matcherRelativeNamespace !== null) {
$matcherIdentifier = $this->matcherRelativeNamespace . "\\{$matcherIdentifier}";
}
// Retrieving the matcher instance from in-memory cache
if (isset($this->matchers[$matcherIdentifier])) {
return $this->matchers[$matcherIdentifier];
}
if (!class_exists($matcherIdentifier)) {
throw new InvalidArgumentException("Invalid matcher class '{$matcherIdentifier}'");
}
$this->matchers[$matcherIdentifier] = new $matcherIdentifier();
if ($this->matchers[$matcherIdentifier] instanceof RepositoryAwareInterface) {
$this->matchers[$matcherIdentifier]->setRepository($this->repository);
}
return $this->matchers[$matcherIdentifier];
}