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

Public Member Functions

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

Data Fields

bool $returnOptionKey = false
 

Protected Attributes

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

Detailed Description

Provides the user with a menu to choose a single option.

After user selection, the option label is returned, except if SingleSelector::$returnOptionKey is TRUE (default is FALSE), in which case the selected key is returned.

Author
everton3x @SuppressWarnings(PHPMD.LongVariable)

Definition at line 17 of file SingleSelector.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 40 of file SingleSelector.php.

Member Function Documentation

◆ read()

read ( )

Implements EntryInterface.

Definition at line 74 of file SingleSelector.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
SingleSelector

Definition at line 68 of file SingleSelector.php.

◆ setSelectionInvalidMessage()

setSelectionInvalidMessage ( string $message)

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

Parameters
string$message
Returns
SingleSelector

Definition at line 55 of file SingleSelector.php.

Field Documentation

◆ $label

readonly string $label
protected

Definition at line 19 of file SingleSelector.php.

◆ $options

readonly array $options
protected

Definition at line 24 of file SingleSelector.php.

◆ $prompt

string $prompt = '> '
protected

Definition at line 26 of file SingleSelector.php.

◆ $returnOptionKey

bool $returnOptionKey = false

Definition at line 32 of file SingleSelector.php.

◆ $selectionInvalidMessage

string $selectionInvalidMessage = null
protected

Definition at line 25 of file SingleSelector.php.


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