화계 구현

This commit is contained in:
2018-11-17 01:44:54 +09:00
parent e9012adaa4
commit c8c026af16
6 changed files with 106 additions and 139 deletions
+6 -2
View File
@@ -112,7 +112,11 @@ class ConstraintHelper{
return [__FUNCTION__];
}
static function NotOccupiedCity():array{
static function NotNeutralDestCity():array{
return [__FUNCTION__];
}
static function NotOccupiedDestCity():array{
return [__FUNCTION__];
}
@@ -128,7 +132,7 @@ class ConstraintHelper{
return [__FUNCTION__];
}
static function OccupiedCity(bool $allowNeutral=true):array{
static function OccupiedCity(bool $allowNeutral=false):array{
return [__FUNCTION__, $allowNeutral];
}
@@ -0,0 +1,32 @@
<?php
namespace sammo\Constraint;
class NotBeNeutral extends Constraint{
const REQ_VALUES = Constraint::REQ_DEST_CITY;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
if(!key_exists('nation', $this->destCity)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require nation in destCity");
}
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
if($this->destCity['nation'] != 0){
return true;
}
$this->reason = "공백지입니다.";
return false;
}
}