arg) == 5){ [$this->key, $this->keyNick, $comp, $this->reqVal, $this->errMsg] = $this->arg; if(!in_array($comp, ['>', '>=', '==', '<=', '<', '!=', '===', '!=='])){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("invalid comparator"); } } else{ if(!$throwExeception){return false; } throw new \InvalidArgumentException("require key, keyNick, comp, reqVal[, errMsg]"); } $this->comp = $comp; $this->maxKey = $this->key.'_max'; if(!key_exists($this->key, $this->general)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("require {$this->key} in general"); } if($this->errMsg!==null && !is_string($this->errMsg)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("{$this->errMsg} must be string or null"); } return true; } public function test():bool{ $this->checkInputValues(); $this->tested = true; $keyNick = $this->keyNick; $reqVal = $this->reqVal; $compList = [ '<'=>function($target, $src){ return ($target < $src)?true:'너무 많습니다.'; }, '<='=>function($target, $src){ return ($target <= $src)?true:'너무 많습니다.'; }, '=='=>function($target, $src)use($keyNick){ return ($target == $src)?true:"올바르지 않은 {$keyNick} 입니다."; }, '!='=>function($target, $src)use($keyNick){ return ($target != $src)?true:"올바르지 않은 {$keyNick} 입니다."; }, '==='=>function($target, $src)use($keyNick){ return ($target === $src)?true:"올바르지 않은 {$keyNick} 입니다."; }, '!=='=>function($target, $src)use($keyNick){ return ($target !== $src)?true:"올바르지 않은 {$keyNick} 입니다."; }, '>='=>function($target, $src){ if($target >= $src){ return true; } if($src == 1){ return '없습니다'; } return '부족합니다.'; }, '>'=>function($target, $src){ if($target > $src){ return true; } if($src == 0){ return '없습니다'; } return '부족합니다.'; }, ]; $comp = $compList[$this->comp]; $result = ($comp)($this->general[$this->key], $reqVal); if($result === true){ return true; } if($this->errMsg){ $this->reason = $this->errMsg; } else{ $josaYi = JosaUtil::pick($keyNick, '이'); $this->reason = "{$keyNick}{$josaYi} {$result}"; } return false; } }