8cedd8a18a
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
35 lines
815 B
PHP
35 lines
815 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Module\Configuration;
|
|
|
|
use InvalidArgumentException;
|
|
use KTXF\Module\Configuration\ConsoleModuleContextInterface;
|
|
use KTXF\Module\Configuration\ModuleContextType;
|
|
|
|
final class ConsoleModuleContext implements ConsoleModuleContextInterface
|
|
{
|
|
/** @var array<class-string,true> */
|
|
private array $commands = [];
|
|
|
|
public function type(): ModuleContextType
|
|
{
|
|
return ModuleContextType::Console;
|
|
}
|
|
|
|
public function registerCommand(string $command): void
|
|
{
|
|
if (trim($command) === '') {
|
|
throw new InvalidArgumentException('Console command class must not be empty');
|
|
}
|
|
|
|
$this->commands[$command] = true;
|
|
}
|
|
|
|
public function commands(): array
|
|
{
|
|
return array_keys($this->commands);
|
|
}
|
|
}
|