| Conditions | 6 |
| Paths | 12 |
| Total Lines | 29 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | 2 | public function perform(ClassesInterface $classes, ReaderInterface $reader): int |
|
| 19 | { |
||
| 20 | 2 | $invalid = []; |
|
| 21 | 2 | foreach ($classes->getClasses() as $class) { |
|
| 22 | 1 | if (!$class->implementsInterface(TokenizationListenerInterface::class)) { |
|
| 23 | 1 | continue; |
|
| 24 | } |
||
| 25 | 1 | $attribute = $reader->firstClassMetadata($class, AbstractTarget::class); |
|
| 26 | 1 | if ($attribute === null) { |
|
| 27 | 1 | $invalid[$class->getName()] = 'Add <comment>#[TargetClass]</comment> or ' . |
|
| 28 | 1 | '<comment>#[TargetAttribute]</comment> attribute to the listener'; |
|
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | 2 | if ($invalid === []) { |
|
| 33 | 1 | $this->info('All listeners are correctly configured.'); |
|
| 34 | |||
| 35 | 1 | return self::SUCCESS; |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | $grid = $this->table(['Listener', 'Suggestion']); |
|
| 39 | |||
| 40 | 1 | foreach ($invalid as $listener => $message) { |
|
| 41 | 1 | $grid->addRow([$listener, $message]); |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | $grid->render(); |
|
| 45 | |||
| 46 | 1 | return self::SUCCESS; |
|
| 47 | } |
||
| 49 |