From f9c8c5ae2e9bb6dd8586730426a5efe6c972b87b Mon Sep 17 00:00:00 2001 From: Jost Baron Date: Fri, 11 Dec 2015 00:47:53 +0100 Subject: [PATCH 1/3] [BUGFIX] Mark national holidays as state-holidays as well If a holiday is a national holiday and it was requested if this day is a holiday in a specific state, the library would indicate "no, it is not a holiday". --- lib/Checkdomain/Holiday/Provider/AbstractProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php index 9b90324..a1e92dc 100644 --- a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php +++ b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php @@ -67,6 +67,10 @@ protected function hasState(Holiday $holiday, $state = null) return true; } + if ($holiday->getNational() === true) { + return true; + } + if (is_array($holiday->getStates()) && in_array($state, $holiday->getStates())) { return true; } From b92aa6fa57ec594fbccfc12f8f7fec443604cf35 Mon Sep 17 00:00:00 2001 From: Jost Baron Date: Fri, 11 Dec 2015 00:55:15 +0100 Subject: [PATCH 2/3] [BUGFIX] Remove use of use old "getNational()" method Fixing my own fix. --- lib/Checkdomain/Holiday/Provider/AbstractProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php index a1e92dc..96d1065 100644 --- a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php +++ b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php @@ -67,7 +67,7 @@ protected function hasState(Holiday $holiday, $state = null) return true; } - if ($holiday->getNational() === true) { + if (empty($holiday->getStates())) { return true; } From 32916cf49e1e01bbb09a718582da263a3c991a5d Mon Sep 17 00:00:00 2001 From: Jost Baron Date: Fri, 11 Dec 2015 10:38:10 +0100 Subject: [PATCH 3/3] [BUGFIX] Fix empty() on return values for old PHP PHP less than 5.5 does not allow empty() on method return values. --- lib/Checkdomain/Holiday/Provider/AbstractProvider.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php index 96d1065..a879a6f 100644 --- a/lib/Checkdomain/Holiday/Provider/AbstractProvider.php +++ b/lib/Checkdomain/Holiday/Provider/AbstractProvider.php @@ -67,11 +67,12 @@ protected function hasState(Holiday $holiday, $state = null) return true; } - if (empty($holiday->getStates())) { + $states = $holiday->getStates(); + if (empty($states)) { return true; } - if (is_array($holiday->getStates()) && in_array($state, $holiday->getStates())) { + if (is_array($states) && in_array($state, $states)) { return true; }