Skip to content

Commit

Permalink
Fix issue with empty arrays; 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMaaarc committed Jun 11, 2024
1 parent df97e39 commit ea77e9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions classes/Models/Openinghours.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))];
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ea77e9c

Please sign in to comment.