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 IO

Provides methods to access the console input and output.

Webmozart\Console\Api\IO\IO implements Webmozart\Console\Api\Formatter\Formatter

Direct known subclasses

Webmozart\Console\IO\BufferedIO, Webmozart\Console\IO\ConsoleIO
Namespace: Webmozart\Console\Api\IO
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at Api/IO/IO.php
Methods summary
public
# __construct( Webmozart\Console\Api\IO\Input $input, Webmozart\Console\Api\IO\Output $output, Webmozart\Console\Api\IO\Output $errorOutput )

Creates an I/O based on the given input and outputs.

Creates an I/O based on the given input and outputs.

Parameters

$input
The standard input.
$output
The standard output.
$errorOutput
The error output.
public Webmozart\Console\Api\IO\Input
# getInput( )

Returns the standard input.

Returns the standard input.

Returns

Webmozart\Console\Api\IO\Input
The input.
public Webmozart\Console\Api\IO\Output
# getOutput( )

Returns the standard output.

Returns the standard output.

Returns

Webmozart\Console\Api\IO\Output
The output.
public Webmozart\Console\Api\IO\Output
# getErrorOutput( )

Returns the error output.

Returns the error output.

Returns

Webmozart\Console\Api\IO\Output
The error output.
public string
# read( integer $length, string $default = null )

Reads the given amount of characters from the standard input.

Reads the given amount of characters from the standard input.

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.

Throws

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

Reads a line from the standard input.

Reads a line from the standard input.

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.

Throws

Webmozart\Console\Api\IO\IOException
If reading fails or if the standard input is closed.
public
# write( string $string, integer $flags = null )

Writes a string to the standard output.

Writes a string to the standard output.

The string is formatted before it is written to the output.

Parameters

$string
The string to write.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the standard output is closed.
public
# writeLine( string $string, integer $flags = null )

Writes a line of text to the standard output.

Writes a line of text to the standard output.

The string is formatted before it is written to the output.

Parameters

$string
The string to write. A newline is appended.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the standard output is closed.
public
# writeRaw( string $string, integer $flags = null )

Writes a string to the standard output without formatting.

Writes a string to the standard output without formatting.

Parameters

$string
The string to write.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the standard output is closed.
public
# writeLineRaw( string $string, integer $flags = null )

Writes a line of text to the standard output without formatting.

Writes a line of text to the standard output without formatting.

Parameters

$string
The string to write. A newline is appended.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the standard output is closed.
public
# error( string $string, integer $flags = null )

Writes a string to the error output.

Writes a string to the error output.

The string is formatted before it is written to the output.

Parameters

$string
The string to write.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the error output is closed.
public
# errorLine( string $string, integer $flags = null )

Writes a line of text to the error output.

Writes a line of text to the error output.

The string is formatted before it is written to the output.

Parameters

$string
The string to write. A newline is appended.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the error output is closed.
public
# errorRaw( string $string, integer $flags = null )

Writes a string to the error output without formatting.

Writes a string to the error output without formatting.

Parameters

$string
The string to write.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the error output is closed.
public
# errorLineRaw( string $string, integer $flags = null )

Writes a line of text to the error output without formatting.

Writes a line of text to the error output without formatting.

Parameters

$string
The string to write. A newline is appended.
$flags

The flags. One of Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE and Webmozart\Console\Api\IO\IO::DEBUG.

Throws

Webmozart\Console\Api\IO\IOException
If writing fails or if the error output is closed.
public
# flush( )

Flushes the outputs and forces all pending text to be written out.

Flushes the outputs and forces all pending text to be written out.

Throws

Webmozart\Console\Api\IO\IOException
If flushing fails or if the outputs are closed.
public
# close( )

Closes the input and the outputs.

Closes the input and the outputs.

public
# setInteractive( boolean $interactive )

Enables or disables interaction with the user.

Enables or disables interaction with the user.

Parameters

$interactive

Whether the I/O may interact with the user. If set to false, all calls to Webmozart\Console\Api\IO\IO::read() and Webmozart\Console\Api\IO\IO::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.

public
# setVerbosity( integer $verbosity )

Sets the verbosity of the output.

Sets the verbosity of the output.

Parameters

$verbosity

One of the constants Webmozart\Console\Api\IO\IO::NORMAL, Webmozart\Console\Api\IO\IO::VERBOSE, Webmozart\Console\Api\IO\IO::VERY_VERBOSE or Webmozart\Console\Api\IO\IO::DEBUG. Only output with the given verbosity level or smaller will be passed through.

public boolean
# isVerbose( )

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::VERBOSE or greater.

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::VERBOSE or greater.

Returns

boolean

Returns true if the verbosity is Webmozart\Console\Api\IO\IO::VERBOSE or greater and false otherwise.

public boolean
# isVeryVerbose( )

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::VERY_VERBOSE or greater.

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::VERY_VERBOSE or greater.

Returns

boolean

Returns true if the verbosity is Webmozart\Console\Api\IO\IO::VERY_VERBOSE or greater and false otherwise.

public boolean
# isDebug( )

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::DEBUG.

Returns whether the verbosity is Webmozart\Console\Api\IO\IO::DEBUG.

Returns

boolean

Returns true if the verbosity is Webmozart\Console\Api\IO\IO::DEBUG and false otherwise.

public integer
# getVerbosity( )

Returns the current verbosity level.

Returns the current verbosity level.

Returns

integer
One of the verbosity constants.
public
# setQuiet( boolean $quiet )

Sets whether all output should be suppressed.

Sets whether all output should be suppressed.

Parameters

$quiet

Pass true to suppress all output and false otherwise.

public boolean
# isQuiet( )

Returns whether all output is suppressed.

Returns whether all output is suppressed.

Returns

boolean

Returns true if all output is suppressed and false otherwise.

public
# setTerminalDimensions( Webmozart\Console\UI\Rectangle $dimensions )

Sets the dimensions of the terminal.

Sets the dimensions of the terminal.

Parameters

$dimensions
The terminal dimensions.
public Webmozart\Console\UI\Rectangle
# getTerminalDimensions( )

Returns the dimensions of the terminal.

Returns the dimensions of the terminal.

Returns

Webmozart\Console\UI\Rectangle
The terminal dimensions.
public
# setFormatter( Webmozart\Console\Api\Formatter\Formatter $formatter )

Sets the output formatter.

Sets the output formatter.

Parameters

$formatter
The output formatter.
public Webmozart\Console\Api\Formatter\Formatter
# getFormatter( )

Returns the output formatter.

Returns the output formatter.

Returns

Webmozart\Console\Api\Formatter\Formatter
The output formatter.
public string
# format( string $string, Webmozart\Console\Api\Formatter\Style $style = null )

Formats the given string.

Formats the given string.

Parameters

$string
The string to format.
$style
The style to use.

Returns

string
The formatted string.

Implementation of

Webmozart\Console\Api\Formatter\Formatter::format()
public string
# removeFormat( string $string )

Removes the format tags from the given string.

Removes the format tags from the given string.

Parameters

$string
The string to remove the format tags from.

Returns

string
The string without format tags.

Implementation of

Webmozart\Console\Api\Formatter\Formatter::removeFormat()
protected Webmozart\Console\UI\Rectangle
# getDefaultTerminalDimensions( )

Returns the default terminal dimensions.

Returns the default terminal dimensions.

Returns

Webmozart\Console\UI\Rectangle
The terminal dimensions.
Constants summary
integer NORMAL

Flag: Always write data.

Flag: Always write data.

# 0
integer VERBOSE

Flag: Only write if the verbosity is "verbose" or greater.

Flag: Only write if the verbosity is "verbose" or greater.

# 1
integer VERY_VERBOSE

Flag: Only write if the verbosity is "very verbose" or greater.

Flag: Only write if the verbosity is "very verbose" or greater.

# 2
integer DEBUG

Flag: Only write if the verbosity is "debug".

Flag: Only write if the verbosity is "debug".

# 4
Webmozart Console API API documentation generated by ApiGen