| Conditions | 5 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public static function discover(string $directory, string $namespace): array |
||
| 34 | { |
||
| 35 | $commands = []; |
||
| 36 | |||
| 37 | foreach (get_directory_classes($directory) as $className) { |
||
| 38 | $commandClass = $namespace . $className; |
||
| 39 | |||
| 40 | if (!class_exists($commandClass)) { |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | $commandReflection = new ReflectionClass($commandClass); |
||
| 45 | |||
| 46 | if (!$commandReflection->isInstantiable() || !$commandReflection->isSubclassOf(QtCommand::class)) { |
||
| 47 | continue; |
||
| 48 | } |
||
| 49 | |||
| 50 | $instance = $commandReflection->newInstance(); |
||
| 51 | |||
| 52 | $commands[] = [ |
||
| 53 | 'class' => $commandClass, |
||
| 54 | 'name' => $instance->getName(), |
||
| 55 | 'description' => $instance->getDescription(), |
||
| 56 | 'help' => $instance->getHelp(), |
||
| 57 | ]; |
||
| 58 | } |
||
| 59 | |||
| 60 | return $commands; |
||
| 61 | } |
||
| 62 | } |