From e1466ac77aea7b3ec39604a918e6a8d701a0be90 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Mon, 14 Mar 2016 12:07:57 +0100 Subject: [PATCH] Allow getting it's at non-existent depth Fixes #114 --- src/Menu/Items/ItemList.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Menu/Items/ItemList.php b/src/Menu/Items/ItemList.php index 5953556..f5d6a65 100644 --- a/src/Menu/Items/ItemList.php +++ b/src/Menu/Items/ItemList.php @@ -495,8 +495,10 @@ public function getItemListsAtDepthRange($from, $to) public function getItemsAtDepth($depth) { $itemsWithDepth = $this->getItemsWithDepth(); - - return new MenuHandler($itemsWithDepth[$depth]); + if (array_key_exists($depth, $itemsWithDepth)) { + return new MenuHandler($itemsWithDepth[$depth]); + } + return new MenuHandler(array()); } /**