Text UI
A simple and fast way to take user input and display output in text mode using PHP.
Loading...
Searching...
No Matches
MultiSelector Class Reference
Inheritance diagram for MultiSelector:
EntryInterface

Public Member Functions

 __construct (string $label, array $options)
 
 setSelectionInvalidMessage (string $message)
 
 setPrompt (string $prompt)
 
 setDefaultOptions (mixed ... $default)
 
 read ()
 
- Public Member Functions inherited from EntryInterface

Data Fields

bool $returnOptionKey = false
 
bool $clearScreen = true
 

Protected Attributes

readonly string $label
 
readonly array $options
 
string $selectionInvalidMessage = null
 
string $prompt = '> '
 
array $selection = []
 

Detailed Description

Provides the user with a menu to choose multiple options.

After user selection ended (end with BLANK ENTER), the options labels are returned, except if MultiSelector::$returnOptionKey is TRUE (default is FALSE), in which case the selected keys are returned.

Author
everton3x @SuppressWarnings(PHPMD.StaticAccess) @SuppressWarnings(PHPMD.LongVariable)

Definition at line 19 of file MultiSelector.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( string $label,
array $options )
Parameters
string$label
array<string>$options
Exceptions
InvalidArgumentException

Definition at line 54 of file MultiSelector.php.

Member Function Documentation

◆ read()

read ( )
Returns
array<int|string> @SuppressWarnings(PHPMD.ElseExpression) @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)

Implements EntryInterface.

Definition at line 108 of file MultiSelector.php.

◆ setDefaultOptions()

setDefaultOptions ( mixed ... $default)

Defines which options will be selected by default.

Parameters
int | string$defaultSequence with the indexes of the selected standard options.
Returns
MultiSelector

Definition at line 94 of file MultiSelector.php.

◆ setPrompt()

setPrompt ( string $prompt)

Sets a prompt message to be displayed in the space reserved for the user to type the option. The default is >.

Parameters
string$prompt
Returns
MultiSelector

Definition at line 82 of file MultiSelector.php.

◆ setSelectionInvalidMessage()

setSelectionInvalidMessage ( string $message)

Sets a message to be displayed when an invalid value is selected.

Parameters
string$message
Returns
MultiSelector

Definition at line 69 of file MultiSelector.php.

Field Documentation

◆ $clearScreen

bool $clearScreen = true

Definition at line 46 of file MultiSelector.php.

◆ $label

readonly string $label
protected

Definition at line 21 of file MultiSelector.php.

◆ $options

readonly array $options
protected

Definition at line 26 of file MultiSelector.php.

◆ $prompt

string $prompt = '> '
protected

Definition at line 28 of file MultiSelector.php.

◆ $returnOptionKey

bool $returnOptionKey = false

Definition at line 39 of file MultiSelector.php.

◆ $selection

array $selection = []
protected

Definition at line 33 of file MultiSelector.php.

◆ $selectionInvalidMessage

string $selectionInvalidMessage = null
protected

Definition at line 27 of file MultiSelector.php.


The documentation for this class was generated from the following file: