src/CliMenu.php
protected function moveSelectionHorizontally(string $direction) : void
    {
        if (!$this->items[$this->selectedItem] instanceof SplitItem) {
            return;
        }

        /** @var SplitItem $item */
        $item = $this->items[$this->selectedItem];
        $itemKeys = array_keys($item->getItems());
        $selectedItemIndex = $item->getSelectedItemIndex();

        do {
            $direction === 'LEFT'
                ? $selectedItemIndex--
                : $selectedItemIndex++;

            if (!array_key_exists($selectedItemIndex, $item->getItems())) {
                $selectedItemIndex = $direction === 'LEFT'
                    ? end($itemKeys)
                    : reset($itemKeys);
            }
        } while (!$item->canSelectIndex($selectedItemIndex));
        
        $item->setSelectedItemIndex($selectedItemIndex);
    }
protected function moveSelectionHorizontally(string $direction) : void
    {
        if (!$this->items[$this->selectedItem] instanceof SplitItem) {
            return;
        }

        /** @var SplitItem $item */
        $item = $this->items[$this->selectedItem];
        $itemKeys = array_keys($item->getItems());
        $selectedItemIndex = $item->getSelectedItemIndex();

        do {
            $direction === 'LEFT'
                ? $selectedItemIndex--
                : $selectedItemIndex++;

            if (!array_key_exists($selectedItemIndex, $item->getItems())) {
                $selectedItemIndex = $direction === 'LEFT'
                    ? end($itemKeys)
                    : reset($itemKeys);
            }
        } while (!$item->canSelectIndex($selectedItemIndex));
        
        $item->setSelectedItemIndex($selectedItemIndex);
    }
Move the selection in a given direction, left / right