refactor
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Model\Constant;
|
||||
|
||||
|
||||
use Enum\StatFilterCellName;
|
||||
|
||||
class Stat extends Constant
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
self::$tableName = 'const_stats';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getBonusNames(): array
|
||||
{
|
||||
return $this->filterByCell(StatFilterCellName::Bonus);
|
||||
}
|
||||
|
||||
private function filterByCell(StatFilterCellName $cellName): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->rows as $row) {
|
||||
if (!$row[$cellName->value]) {
|
||||
continue;
|
||||
}
|
||||
if ($row['sys_name'] === 'level') {
|
||||
$row['sys_name'] = 'lvl';
|
||||
}
|
||||
$result[$row['sys_name']] = $row['name'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getRequirementNames(): array
|
||||
{
|
||||
return $this->filterByCell(StatFilterCellName::Requirement);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user