Files
kiri-core/System/Abstracts/Component.php
T

56 lines
795 B
PHP
Raw Normal View History

2020-08-31 01:27:08 +08:00
<?php
/**
* Created by PhpStorm.
* User: whwyy
* Date: 2018/3/30 0030
* Time: 14:28
*/
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-12-17 14:09:14 +08:00
2021-08-11 01:04:57 +08:00
namespace Kiri\Abstracts;
2020-08-31 01:27:08 +08:00
use Exception;
2020-12-17 14:12:44 +08:00
2021-02-23 18:31:30 +08:00
use JetBrains\PhpStorm\Pure;
2021-08-11 01:04:57 +08:00
use Kiri\Exception\ComponentException;
use Kiri\Kiri;
2020-08-31 01:27:08 +08:00
/**
* Class Component
2021-08-11 01:04:57 +08:00
* @package Kiri\Kiri\Base
2020-08-31 01:27:08 +08:00
*/
class Component extends BaseObject
{
2020-09-02 15:37:06 +08:00
/**
* @param $name
* @param $value
* @throws Exception
*/
public function __set($name, $value)
{
if (property_exists($this, $name)) {
$this->$name = $value;
} else {
parent::__set($name, $value);
}
}
2020-08-31 01:27:08 +08:00
/**
* @param $name
* @return mixed
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function __get($name): mixed
2020-08-31 01:27:08 +08:00
{
2020-09-02 15:37:06 +08:00
if (property_exists($this, $name)) {
2020-08-31 01:27:08 +08:00
return $this->$name ?? null;
} else {
return parent::__get($name);
}
}
}