From cedccb60598c1977c6e400c3001c7b492e553c12 Mon Sep 17 00:00:00 2001 From: Sacha Telgenhof Date: Mon, 23 Oct 2023 00:29:38 +0900 Subject: [PATCH] Optimize the between filter class. Using a single return statement in the accept() method as it is more efficient than using two return statements, and it avoids the need to evaluate the expression in the second return statement if the first return statement is evaluated to true. Signed-off-by: Sacha Telgenhof --- src/Yasumi/Filters/BetweenFilter.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Yasumi/Filters/BetweenFilter.php b/src/Yasumi/Filters/BetweenFilter.php index 2e25215b8..b6a6e50d9 100644 --- a/src/Yasumi/Filters/BetweenFilter.php +++ b/src/Yasumi/Filters/BetweenFilter.php @@ -63,10 +63,8 @@ public function accept(): bool { $holiday = $this->getInnerIterator()->current()->format(self::DATE_FORMAT); - if ($this->equal) { - return $holiday >= $this->startDate && $holiday <= $this->endDate; - } - - return $holiday > $this->startDate && $holiday < $this->endDate; + return $this->equal + ? $holiday >= $this->startDate && $holiday <= $this->endDate + : $holiday > $this->startDate && $holiday < $this->endDate; } }