| Total Complexity | 9 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE), NamedArgumentConstructor] |
||
| 17 | final class TargetClass implements ListenerDefinitionInterface |
||
| 18 | { |
||
| 19 | use TargetTrait; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param class-string $class |
||
|
|
|||
| 23 | * @param non-empty-string|null $scope |
||
| 24 | */ |
||
| 25 | public function __construct( |
||
| 29 | } |
||
| 30 | |||
| 31 | public function filter(array $classes): \Generator |
||
| 32 | { |
||
| 33 | $target = new \ReflectionClass($this->class); |
||
| 34 | |||
| 35 | foreach ($classes as $class) { |
||
| 36 | if (!$target->isTrait()) { |
||
| 37 | if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
||
| 38 | yield $class->getName(); |
||
| 39 | } |
||
| 40 | |||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | // Checking using traits |
||
| 45 | if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) { |
||
| 46 | yield $class->getName(); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getCacheKey(): string |
||
| 52 | { |
||
| 53 | return \md5($this->class . $this->scope); |
||
| 54 | } |
||
| 55 | |||
| 56 | public function getScope(): ?string |
||
| 59 | } |
||
| 60 | } |
||
| 61 |