You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
730 B
PHP
27 lines
730 B
PHP
<?php
|
|
|
|
namespace jrosset\CliProgram;
|
|
|
|
use ReflectionClass;
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
/**
|
|
* A basic command
|
|
*/
|
|
class BaseCommand extends Command {
|
|
/**
|
|
* Initialize the command
|
|
*
|
|
* @param string|null $name The command name, Null = class name
|
|
* @param string ...$aliases The command aliases
|
|
*/
|
|
public function __construct (?string $name = null, string ...$aliases) {
|
|
if ($name === null) {
|
|
$classShortName = (new ReflectionClass($this))->getShortName();
|
|
$name = mb_strtolower(mb_substr($classShortName, 0, 1)) . mb_substr($classShortName, 1);
|
|
}
|
|
|
|
parent::__construct($name);
|
|
$this->setAliases($aliases);
|
|
}
|
|
} |