| Conditions | 3 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | 1 | public function perform( |
|
| 19 | TokenizerListenerRegistryInterface $registry, |
||
| 20 | DirectoriesInterface $dirs, |
||
| 21 | ReaderInterface $reader |
||
| 22 | ): int { |
||
| 23 | 1 | $listeners = \method_exists($registry, 'getListenerClasses') ? $registry->getListenerClasses() : []; |
|
| 24 | |||
| 25 | 1 | $grid = $this->table(['Listener', 'Suggestion']); |
|
| 26 | 1 | foreach ($listeners as $class) { |
|
| 27 | 1 | $ref = new \ReflectionClass($class); |
|
| 28 | 1 | $attribute = $reader->firstClassMetadata($ref, AbstractTarget::class); |
|
| 29 | 1 | $suggestion = match (true) { |
|
| 30 | 1 | $attribute === null => 'Add <comment>#[TargetClass]</comment> or ' . |
|
| 31 | 1 | '<comment>#[TargetAttribute]</comment> attribute to the listener', |
|
| 32 | 1 | default => '<info>Listener is configured correctly</info>', |
|
| 33 | 1 | }; |
|
| 34 | 1 | $grid->addRow([ |
|
| 35 | 1 | $class . "\n" . \sprintf('<fg=blue>%s</>', \str_replace($dirs->get('root'), '', $ref->getFileName())), |
|
| 36 | 1 | $suggestion, |
|
| 37 | 1 | ]); |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $grid->render(); |
|
| 41 | |||
| 42 | 1 | return self::SUCCESS; |
|
| 43 | } |
||
| 45 |