Text UI
A simple and fast way to take user input and display output in text mode using PHP.
|
Public Member Functions | |
__construct (string $label) | |
setParser (?object $parser) | |
setDecimalPoint (string $decimalPoint) | |
setThousandsSep (string $thousandsSep) | |
setDecimals (int $decimals) | |
setOutputType (string $type) | |
read () | |
Public Member Functions inherited from EntryInterface |
Protected Member Functions | |
defaultParser (string $entry) | |
Protected Attributes | |
readonly string | $label |
object | $parser = null |
string | $decimalPoint |
string | $thousandsSep |
string | $outputType = 'float' |
int | $decimals = null |
Receives numbers from the user.
Accepts decimal places, thousands separator, decimal point and custom parser.
Definition at line 15 of file NumberEntry.php.
__construct | ( | string | $label | ) |
Definition at line 24 of file NumberEntry.php.
|
protected |
Default parser and will always be applied unless a custom parser is provided by NumberEntry::setParser().
The default parser applies the following operations on user input (in the following order):
.
or ,
..
.string | $entry |
Definition at line 55 of file NumberEntry.php.
read | ( | ) |
Reads the user input.
Implements EntryInterface.
Definition at line 158 of file NumberEntry.php.
setDecimalPoint | ( | string | $decimalPoint | ) |
Sets the decimal point.
string | $decimalPoint |
Definition at line 101 of file NumberEntry.php.
setDecimals | ( | int | $decimals | ) |
Sets a decimal places.
int | $decimals |
Definition at line 125 of file NumberEntry.php.
setOutputType | ( | string | $type | ) |
Sets the output type.
string | $type | Only float|double|int|integer allowed. |
InvalidArgumentException |
Definition at line 139 of file NumberEntry.php.
setParser | ( | ?object | $parser | ) |
Sets a parser.
$parser must be a callable type that will be executed as NumberEntry::parser() and must receive as its only argument the user's string and return a float or int.
null | object | $parser |
Definition at line 89 of file NumberEntry.php.
setThousandsSep | ( | string | $thousandsSep | ) |
Sets a thousands separator.
string | $thousandsSep |
Definition at line 113 of file NumberEntry.php.
|
protected |
Definition at line 19 of file NumberEntry.php.
|
protected |
Definition at line 22 of file NumberEntry.php.
|
protected |
Definition at line 17 of file NumberEntry.php.
|
protected |
Definition at line 21 of file NumberEntry.php.
|
protected |
Definition at line 18 of file NumberEntry.php.
|
protected |
Definition at line 20 of file NumberEntry.php.