WIP: разгрузка User:class от сторонних методов.
This commit is contained in:
38
_incl_data/class/DTO/KnowledgeTempleItem.php
Normal file
38
_incl_data/class/DTO/KnowledgeTempleItem.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace DTO;
|
||||
|
||||
use Core\ConversionHelper;
|
||||
use ItemModel;
|
||||
|
||||
class KnowledgeTempleItem
|
||||
{
|
||||
public int $id;
|
||||
public int $type;
|
||||
public string $name;
|
||||
public int $level;
|
||||
|
||||
private int $rowId;
|
||||
/**
|
||||
* @param array $item
|
||||
*/
|
||||
public function __construct(array $item)
|
||||
{
|
||||
$this->rowId = $item['id'];
|
||||
$this->id = intval($item['item_id']);
|
||||
$this->type = intval($item['type']);
|
||||
$this->name = $item['name'];
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
$itemData = array_merge(
|
||||
ConversionHelper::dataStringToArray(ItemModel::getItemData($this->id)),
|
||||
ConversionHelper::dataStringToArray($item['data']),
|
||||
);
|
||||
$this->level = intval($itemData['tr_lvl']);
|
||||
}
|
||||
|
||||
public function exists(): bool
|
||||
{
|
||||
return !empty($this->rowId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user