Class RStdin
Handy for for command line application that use keyboard input. For testing purposes the input can be faked.
Example
<?php
require_once("rawdev/RawDev.php");
require_once(RAWDEV_LIB.'/Util/Stdin.php');
# regular use
$input = RStdin::read('Please enter input: ');
print "$inputn";
# testing use
RStdin::$buffer[] = 'hello'; # for testing purposes the input buffer can be set
$input = RStdin::read('Please enter input: ');
print "$inputn";
?>
Vars
static string[] $buffer
A fifo buffer of faked inputs.
Functions
static string function read($message, $trim)
Reads the keyboard input ending with [enter]. The input can be faked for testing purposes (see sample).
$message | string | The message that is displayed on the same line that the input is typed. |
$trim | bool | Wheter the input should be trimmed (default: yes). |
returns | string | The input that was entered (ending with a carriage return when not trimmed). |
|