| Total Complexity | 11 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class DefaultProvider implements Provider |
||
| 9 | { |
||
| 10 | |||
| 11 | /** @var Command[]|string[] */ |
||
| 12 | protected $commands = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Handle adding commands to a bot |
||
| 16 | * |
||
| 17 | * @param Bot $bot |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | public function register(Bot $bot) |
||
| 21 | { |
||
| 22 | $manager = $bot->commands(); |
||
| 23 | |||
| 24 | // Add any subclass commands |
||
| 25 | foreach ($this->commands as $command) { |
||
| 26 | $manager->addCommand($command); |
||
| 27 | } |
||
| 28 | |||
| 29 | // Add all the default provided commands |
||
| 30 | foreach ($this->findCommands() as $command) { |
||
| 31 | $manager->addCommand($command); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $manager; |
||
| 35 | } |
||
| 36 | |||
| 37 | |||
| 38 | /** |
||
| 39 | * Find commands in the directory we expect to make the most of them |
||
| 40 | * |
||
| 41 | * @return iterable |
||
| 42 | */ |
||
| 43 | public function findCommands(): iterable |
||
| 60 | // Ignore classes we can't reflect |
||
| 61 | } |
||
| 65 | } |