51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace admin\components\UI\Elements;
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: chatfeed
|
|
* Date: 2022/5/19
|
|
* Time: 7:40 PM
|
|
*/
|
|
abstract class Element implements \ArrayAccess
|
|
{
|
|
private array $_attrs = [];
|
|
public static function create(array $arr)
|
|
{
|
|
$el = new static();
|
|
foreach ($arr as $k => $v) {
|
|
$el->{$k} = $v;
|
|
}
|
|
return $el;
|
|
}
|
|
public function toArray(){
|
|
return $this->_attrs;
|
|
}
|
|
|
|
public function offsetGet($offset)
|
|
{
|
|
return $this->_attrs[$offset];
|
|
// TODO: Implement offsetGet() method.
|
|
}
|
|
|
|
public function offsetSet($offset, $value)
|
|
{
|
|
$this->_attrs[$offset] = $value;
|
|
return true;
|
|
// TODO: Implement offsetSet() method.
|
|
}
|
|
public function offsetUnset($offset)
|
|
{
|
|
unset($this->_attrs[$offset]);
|
|
return true;
|
|
// TODO: Implement offsetUnset() method.
|
|
}
|
|
|
|
public function offsetExists($offset)
|
|
{
|
|
return isset($this->_attrs[$offset]);
|
|
// TODO: Implement offsetExists() method.
|
|
}
|
|
}
|