nationID = $this->nation['nation']; $this->destNationID = $this->destNation['nation']; $this->disallowStatus = $this->arg; foreach($this->disallowStatus as $dipCode => $errMsg){ if(!is_int($dipCode)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("dipCode $dipCode must be int"); } if(!is_string($errMsg)){ if(!$throwExeception){return false; } throw new \InvalidArgumentException("dipCode $errMsg must be string"); } } return true; } public function test():bool{ $this->checkInputValues(); $this->tested = true; $db = DB::db(); $state = $db->queryFirstField( 'SELECT state FROM diplomacy WHERE me = %i AND you = %i AND `state` IN %li LIMIT 1', $this->nationID, $this->destNationID, array_keys($this->disallowStatus) ); if($state === null){ return true; } $this->reason = $this->disallowStatus[$state]; return false; } }