Skip to content

Commit 3b64266

Browse files
authored
Merge pull request #86 from Lynesth/patch-5
Adding public functions addItems and setItems
2 parents 3d83d9a + b311969 commit 3b64266

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/CliMenu.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ public function addItem(MenuItemInterface $item) : void
143143
}
144144
}
145145

146+
/**
147+
* Add multiple Items to the menu
148+
*/
149+
public function addItems(array $items) : void
150+
{
151+
foreach ($items as $item) {
152+
$this->items[] = $item;
153+
}
154+
155+
if (count($this->items) === count($items)) {
156+
$this->selectFirstItem();
157+
}
158+
}
159+
160+
/**
161+
* Set Items of the menu
162+
*/
163+
public function setItems(array $items) : void
164+
{
165+
$this->items = $items;
166+
167+
$this->selectFirstItem();
168+
}
169+
146170
/**
147171
* Set the selected pointer to the first selectable item
148172
*/

0 commit comments

Comments
 (0)