Files
kiri-core/Console/Command.php
T

87 lines
1.6 KiB
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-08-31 01:27:08 +08:00
2020-09-03 00:15:57 +08:00
namespace Console;
2020-08-31 01:27:08 +08:00
2021-03-25 00:15:46 +08:00
use ReflectionException;
2020-08-31 01:27:08 +08:00
use Snowflake\Abstracts\BaseObject;
2021-03-25 00:15:46 +08:00
use Snowflake\Abstracts\TraitApplication;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
2020-08-31 01:27:08 +08:00
/**
* Class Command
2020-09-03 00:15:57 +08:00
* @package Console
2020-08-31 01:27:08 +08:00
*/
abstract class Command extends BaseObject implements CommandInterface
{
2021-03-25 00:15:46 +08:00
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 Snowflake::app()->has($name);
}
/**
* @param $name
* @return mixed
* @throws ReflectionException
* @throws ComponentException
* @throws NotFindClassException
*/
private function get($name): mixed
{
return Snowflake::app()->get($name);
}
2020-08-31 01:27:08 +08:00
}