diff --git a/classes/Models/Openinghours.php b/classes/Models/Openinghours.php index d3271dc..4fc33bb 100644 --- a/classes/Models/Openinghours.php +++ b/classes/Models/Openinghours.php @@ -134,18 +134,26 @@ public function setSpecialOpeninghours(array $openinghours) } /** - * @return Openinghour + * @return Openinghour|null */ public function getActiveOpeninghour() { + if (empty($this->openinghours)) { + return null; + } + return $this->openinghours[array_search(true, array_map(fn($oh) => $oh->isActive(), $this->openinghours))]; } /** - * @return SpecialOpeninghour + * @return SpecialOpeninghour|null */ public function getActiveSpecialOpeninghour() { + if (empty($this->specialOpeninghours)) { + return null; + } + return $this->specialOpeninghours[array_search(true, array_map(fn($oh) => $oh->isActive(), $this->specialOpeninghours))]; } diff --git a/composer.json b/composer.json index e879e77..e198458 100755 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Openinghours plugin to manage and display opening hours.", "license": "MIT", "type": "kirby-plugin", - "version": "0.0.8", + "version": "0.0.9", "authors": [ { "name": "Marc Stampfli",