game/_incl_data/class/DTO/KnowledgeTempleItem.php

41 lines
836 B
PHP
Raw Normal View History

<?php
namespace DTO;
use Helper\Conversion;
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'];
// Общий + конкретный.
$itemData = array_merge(
Conversion::dataStringToArray(ItemModel::getItemData($this->id)),
Conversion::dataStringToArray($item['data']),
);
$this->level = intval($itemData['tr_lvl']);
}
public function exists(): bool
{
return !empty($this->rowId);
}
}