Files
core/hwe/sammo/Constraint/RemainCityTrust.php
T
Hide_D ee8854451c fix: phan 지시에 따라 일부 버그 수정
- null && key_exists 버그
- or assign이 integer 대상이므로 직접 연산
- false 대신 0 입력한 곳 수정
- 자체 Deprecate 처리한 함수 회피
- 초기화되지 않은 [] 확인하여 처리
- sleep은 정수만 받으므로 usleep으로 변경
- 선언하지 않고 그냥 사용하던 member 변수 선언
- boolean operation 순서 틀린 부분 수정
2021-08-12 23:58:20 +09:00

45 lines
1.1 KiB
PHP

<?php
namespace sammo\Constraint;
use \sammo\JosaUtil;
class RemainCityTrust extends Constraint{
const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_STRING_ARG;
protected $key;
protected $maxKey;
protected $maxVal;
protected $keyNick;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
return false;
}
$this->keyNick = $this->arg;
$this->key = 'trust';
$this->maxVal = 100;
if(!key_exists($this->key, $this->city)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require {$this->key} in city");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
$keyNick = $this->keyNick;
if($this->city[$this->key] < $this->maxVal){
return true;
}
$josaUn = JosaUtil::pick($keyNick, '은');
$this->reason = "{$keyNick}{$josaUn} 충분합니다.";
return false;
}
}