This commit is contained in:
2023-08-28 12:01:30 +08:00
parent 4a607a5687
commit 9b4f5d59dc
7 changed files with 234 additions and 192 deletions
+62 -52
View File
@@ -22,66 +22,76 @@ class Component implements Configure
{
/**
* BaseAbstract constructor.
*/
public function __construct()
{
}
/**
* BaseAbstract constructor.
*/
public function __construct()
{
}
/**
* @return void
*/
public function init(): void
{
}
/**
* @return void
*/
public function init(): void
{
}
/**
* @return string
*/
#[Pure] public static function className(): string
{
return static::class;
}
/**
* @return string
*/
#[Pure] public static function className(): string
{
return static::class;
}
/**
* @param string $name
* @return mixed
* @throws Exception
*/
public function __get(string $name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method)) {
return $this->{$method}();
} else if (method_exists($this, $name)) {
return $this->{$name};
} else {
throw new Exception('Unable getting property ' . get_called_class() . '::' . $name);
}
}
/**
* @return Kiri\Error\StdoutLogger
* @throws \ReflectionException
*/
public function getLogger(): Kiri\Error\StdoutLogger
{
return Kiri::getLogger();
}
/**
* @param string $name
* @param $value
* @return void
* @throws Exception
*/
public function __set(string $name, $value): void
{
$method = 'set' . ucfirst($name);
if (method_exists($this, $method)) {
$this->{$method}($value);
} else if (method_exists($this, $name)) {
$this->{$name} = $value;
} else {
throw new Exception('Unable setting property ' . get_called_class() . '::' . $name);
}
}
/**
* @param string $name
* @return mixed
* @throws Exception
*/
public function __get(string $name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method)) {
return $this->{$method}();
} else if (method_exists($this, $name)) {
return $this->{$name};
} else {
throw new Exception('Unable getting property ' . get_called_class() . '::' . $name);
}
}
/**
* @param string $name
* @param $value
* @return void
* @throws Exception
*/
public function __set(string $name, $value): void
{
$method = 'set' . ucfirst($name);
if (method_exists($this, $method)) {
$this->{$method}($value);
} else if (method_exists($this, $name)) {
$this->{$name} = $value;
} else {
throw new Exception('Unable setting property ' . get_called_class() . '::' . $name);
}
}
}