Skip to content

Commit

Permalink
Remove instatioation
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Sep 6, 2023
1 parent 2ee4f5c commit e87032e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Matcher/AnnotatedWithMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@

namespace Ray\Aop\Matcher;

use Doctrine\Common\Annotations\Reader;
use Ray\Aop\AbstractMatcher;
use Ray\ServiceLocator\ServiceLocator;
use ReflectionClass;
use ReflectionMethod;

final class AnnotatedWithMatcher extends AbstractMatcher
{
/** @var Reader */
private $reader;

public function __construct()
{
$this->reader = ServiceLocator::getReader();

parent::__construct();
}

/**
* {@inheritDoc}
*/
public function matchesClass(ReflectionClass $class, array $arguments): bool
{
/** @var array<class-string> $arguments */
[$annotation] = $arguments;
$annotation = ServiceLocator::getReader()->getClassAnnotation($class, $annotation);
$annotation = $this->reader->getClassAnnotation($class, $annotation);

return (bool) $annotation;
}
Expand All @@ -30,7 +41,7 @@ public function matchesMethod(ReflectionMethod $method, array $arguments): bool
{
/** @var array<class-string> $arguments */
[$annotation] = $arguments;
$annotation = ServiceLocator::getReader()->getMethodAnnotation($method, $annotation);
$annotation = $this->reader->getMethodAnnotation($method, $annotation);

return (bool) $annotation;
}
Expand Down

0 comments on commit e87032e

Please sign in to comment.