Files
kiri-core/System/Core/Dtl.php
T

61 lines
786 B
PHP
Raw Normal View History

2020-09-02 19:34:45 +08:00
<?php
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-09-02 19:34:45 +08:00
namespace Snowflake\Core;
use Exception;
use Snowflake\Abstracts\Component;
/**
* Class Dtl
* @package Snowflake\Core
*/
class Dtl extends Component
{
2020-10-29 18:17:25 +08:00
protected array $params;
2020-09-02 19:34:45 +08:00
/**
* Dtl constructor.
* @param $params
*/
public function __construct($params)
{
parent::__construct([]);
$this->params = $params;
}
/**
2020-12-17 14:09:14 +08:00
* @return array
2020-09-02 19:34:45 +08:00
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function toArray(): array
2020-09-02 19:34:45 +08:00
{
if (!is_array($this->params)) {
return ArrayAccess::toArray($this->params);
}
return $this->params;
}
/**
* @param $name
2020-12-17 14:09:14 +08:00
* @return mixed
2020-09-02 19:34:45 +08:00
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function get($name): mixed
2020-09-02 19:34:45 +08:00
{
$array = $this->toArray();
if (!isset($array[$name])) {
return null;
}
return $array[$name];
}
}