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

61 lines
771 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
2021-08-11 01:04:57 +08:00
namespace Kiri\Core;
2020-09-02 19:34:45 +08:00
use Exception;
2021-08-11 01:04:57 +08:00
use Kiri\Abstracts\Component;
2020-09-02 19:34:45 +08:00
/**
* Class Dtl
2021-08-11 01:04:57 +08:00
* @package Kiri\Core
2020-09-02 19:34:45 +08:00
*/
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];
}
}