Menus
The Menu Class provides a horizontal menu where the user types the desired selection, but need only type as many unique characters are needed. There can also be a default choice presented, which only requires carriage return to select.

Software Documentation
The following section documents the Menu class.
Menu Class
There is one decorator class, Menu, that requires a Clio object to decorate.
Constructor
Pass in the Clio object (which should have one instance to represent the physical terminal). Define the color scheme for the menu. If it is not specified, then a black, white and gray colors are used as shown. The title can be changed or set to null if not desired.
__construct($clio, StyleInterface $titleStyle = null, StyleInterface $highlightStyle = null, StyleInterface $choiceStyle = null, $title = "Menu" )
Parameters | ||
---|---|---|
Name | Type | Description |
$clio | Clio | Clio object |
$titleStyle | Style Object | The styling of the first characters in the menu |
$highlightStyle | Style Object | The styling of the choice characters in the menu |
$choiceStyle | Style Object | The styling of the rest of the characters in each choice |
$title | string | The first characters shown in the menu, set to null if no title is desired. |
setTitle
Set the first characters shown in the menu, defaulted to "Menu".
setTitle($title)
Parameters | ||
---|---|---|
Name | Type | Description |
$title | string | the title of the menu |
menu
Display the menu prompting the user for an array of choices. This method will wait until the user selects a proper choice (which it then returns) or 10 attempts whichever is sooner. If the default is null, then no default is presented at the end of the menu and the user must type characters to make a selection. If a default is presented, it will be shown at the end of the menu in brackets to indicate that the user only need to hit return to select that selection. The user can also type the default selection and it will affect the number of unique characters needed for the choices presented, as choice itself.
[string] menu($choices, $default = null)
Parameters | ||
---|---|---|
Name | Type | Description |
$choices | string[] | The array of choices, with the last one being the default choice |
$default | string | null | whether to provide a default choice |