From eccd883edc0173108806e6637a943d758adb4381 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 5 Aug 2023 07:59:26 +0000 Subject: [PATCH] feat: NotOccupiedCity constraint --- hwe/sammo/Constraint/ConstraintHelper.php | 4 +++ hwe/sammo/Constraint/NotOccupiedCity.php | 37 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 hwe/sammo/Constraint/NotOccupiedCity.php diff --git a/hwe/sammo/Constraint/ConstraintHelper.php b/hwe/sammo/Constraint/ConstraintHelper.php index e354eaf6..e90bf713 100644 --- a/hwe/sammo/Constraint/ConstraintHelper.php +++ b/hwe/sammo/Constraint/ConstraintHelper.php @@ -156,6 +156,10 @@ class ConstraintHelper{ return [__FUNCTION__]; } + static function NotOccupiedCity():array{ + return [__FUNCTION__]; + } + static function NotOccupiedDestCity():array{ return [__FUNCTION__]; } diff --git a/hwe/sammo/Constraint/NotOccupiedCity.php b/hwe/sammo/Constraint/NotOccupiedCity.php new file mode 100644 index 00000000..a3026569 --- /dev/null +++ b/hwe/sammo/Constraint/NotOccupiedCity.php @@ -0,0 +1,37 @@ +general)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in general"); + } + + if(!key_exists('nation', $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require nation in city"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->city['nation'] != $this->general['nation']){ + return true; + } + + $this->reason = "아국입니다."; + return false; + } +} \ No newline at end of file