Files
kiri-core/Console/Command.php
T
as2252258@163.com 682246df28 modify
2021-08-11 01:04:57 +08:00

87 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Console;
use ReflectionException;
use Kiri\Abstracts\BaseObject;
use Kiri\Abstracts\TraitApplication;
use Kiri\Exception\ComponentException;
use Kiri\Exception\NotFindClassException;
use Kiri\Kiri;
/**
* Class Command
* @package Console
*/
abstract class Command extends BaseObject implements CommandInterface
{
use TraitApplication;
public string $command = '';
public string $description = '';
/**
* @return string
* 返回执行的命令名称
*/
public function getName(): string
{
return $this->command;
}
/**
* @return string
*
* 返回命令描述
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param $name
* @return mixed
* @throws ComponentException
* @throws NotFindClassException
* @throws ReflectionException
*/
public function __get($name): mixed
{
if ($this->has($name)) {
return $this->get($name);
}
return parent::__get($name); // TODO: Change the autogenerated stub
}
/**
* @param $name
* @return bool
*/
private function has($name): bool
{
return Kiri::app()->has($name);
}
/**
* @param $name
* @return mixed
* @throws ReflectionException
* @throws ComponentException
* @throws NotFindClassException
*/
private function get($name): mixed
{
return Kiri::app()->get($name);
}
}