readLine() public method

Reads a line from the input stream.
public readLine ( string $default = null, integer $length = null ) : string
$default string The default to return if interaction is disabled.
$length integer The maximum number of characters to read. If `null`, all characters up to the first newline are returned.
return string The characters read from the input stream.
Esempio n. 1
0
 /**
  * Reads a line from the standard input.
  *
  * @param string $default The default to return if interaction is disabled.
  * @param int    $length  The maximum number of characters to read. If
  *                        `null`, all characters up to the first newline are
  *                        returned.
  *
  * @return string The characters read from the input.
  *
  * @throws IOException If reading fails or if the standard input is closed.
  */
 public function readLine($default = null, $length = null)
 {
     return $this->input->readLine($default, $length);
 }
Esempio n. 2
0
 public function testReadLineReturnsDefaultIfNotInteractive()
 {
     $this->stream->set(self::LOREM_IPSUM);
     $this->input->setInteractive(false);
     $this->assertSame('Default', $this->input->readLine('Default'));
 }