初始化仓库
This commit is contained in:
50
admin/components/UI/Elements/Element.php
Normal file
50
admin/components/UI/Elements/Element.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user