Overview

Namespaces

  • Webmozart
    • Console
      • Adapter
      • Api
        • Application
        • Args
          • Format
        • Command
        • Config
        • Event
        • Formatter
        • IO
        • Resolver
      • Args
      • Config
      • Formatter
      • Handler
        • Help
      • IO
        • InputStream
        • OutputStream
      • Process
      • Resolver
      • UI
        • Alignment
        • Component
        • Help
        • Layout
        • Style
      • Util

Classes

  • Input
  • IO
  • Output

Interfaces

  • InputStream
  • OutputStream

Exceptions

  • IOException
  • Overview
  • Namespace
  • Class

Class Input

The console input.

This class wraps an input stream and adds convenience functionality for reading that stream.

Namespace: Webmozart\Console\Api\IO
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at Api/IO/Input.php
Methods summary
public
# __construct( Webmozart\Console\Api\IO\InputStream $stream )

Creates an input for the given input stream.

Creates an input for the given input stream.

Parameters

$stream
The input stream.
public string
# read( integer $length, string $default = null )

Reads the given amount of characters from the input stream.

Reads the given amount of characters from the input stream.

Parameters

$length
The number of characters to read.
$default
The default to return if interaction is disabled.

Returns

string
The characters read from the input stream.

Throws

Webmozart\Console\Api\IO\IOException
If reading fails or if the input stream is closed.
public string
# readLine( string $default = null, integer $length = null )

Reads a line from the input stream.

Reads a line from the input stream.

Parameters

$default
The default to return if interaction is disabled.
$length

The maximum number of characters to read. If null, all characters up to the first newline are returned.

Returns

string
The characters read from the input stream.

Throws

Webmozart\Console\Api\IO\IOException
If reading fails or if the input stream is closed.
public
# close( )

Closes the input.

Closes the input.

public boolean
# isClosed( )

Returns whether the input is closed.

Returns whether the input is closed.

Returns

boolean

Returns true if the input is closed and false otherwise.

public
# setStream( Webmozart\Console\Api\IO\InputStream $stream )

Sets the underlying stream.

Sets the underlying stream.

Parameters

$stream
The input stream.
public Webmozart\Console\Api\IO\InputStream
# getStream( )

Returns the underlying stream.

Returns the underlying stream.

Returns

Webmozart\Console\Api\IO\InputStream
The input stream.
public
# setInteractive( boolean $interactive )

Enables or disables interaction with the user.

Enables or disables interaction with the user.

Parameters

$interactive

Whether the inputmay interact with the user. If set to false, all calls to Webmozart\Console\Api\IO\Input::read() and Webmozart\Console\Api\IO\Input::readLine() will immediately return the default value.

public boolean
# isInteractive( )

Returns whether the user may be asked for input.

Returns whether the user may be asked for input.

Returns

boolean

Returns true if the user may be asked for input and false otherwise.

Webmozart Console API API documentation generated by ApiGen