PHP Class Webmozart\Console\Api\IO\Output

This class wraps an output stream and adds convenience functionality for writing that stream.
Since: 1.0
Author: Bernhard Schussek ([email protected])
Inheritance: implements Webmozart\Console\Api\Formatter\Formatter
显示文件 Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
__construct ( Webmozart\Console\Api\IO\OutputStream $stream, Webmozart\Console\Api\Formatter\Formatter $formatter = null ) Creates an output for the given output stream.
close ( ) Closes the output.
flush ( ) Forces all pending text to be written out.
format ( $string, Style $style = null )
getFormatter ( ) : Webmozart\Console\Api\Formatter\Formatter Returns the output formatter.
getStream ( ) : Webmozart\Console\Api\IO\OutputStream Returns the underlying stream.
getVerbosity ( ) : integer Returns the current verbosity level.
isClosed ( ) : boolean Returns whether the output is closed.
isDebug ( ) : boolean Returns whether the verbosity level is {@link IO::DEBUG}.
isQuiet ( ) : boolean Returns whether output is suppressed completely.
isVerbose ( ) : boolean Returns whether the verbosity level is {@link IO::VERBOSE} or greater.
isVeryVerbose ( ) : boolean Returns whether the verbosity level is {@link IO::VERY_VERBOSE} or greater.
removeFormat ( $string )
setFormatter ( Webmozart\Console\Api\Formatter\Formatter $formatter ) Sets the output formatter.
setQuiet ( boolean $quiet ) Sets whether output should be suppressed completely.
setStream ( Webmozart\Console\Api\IO\OutputStream $stream ) Sets the underlying stream.
setVerbosity ( integer $verbosity ) Sets the verbosity level of the output.
write ( string $string, integer $flags = null ) Writes a string to the output stream.
writeLine ( string $string, integer $flags = null ) Writes a line of text to the output stream.
writeLineRaw ( string $string, integer $flags = null ) Writes a line of text to the output stream without formatting.
writeRaw ( string $string, integer $flags = null ) Writes a string to the output stream without formatting.

Protected Methods

Method Description
mayWrite ( integer $flags ) : boolean Returns whether an output may be written for the given flags.

Method Details

__construct() public method

Creates an output for the given output stream.
public __construct ( Webmozart\Console\Api\IO\OutputStream $stream, Webmozart\Console\Api\Formatter\Formatter $formatter = null )
$stream Webmozart\Console\Api\IO\OutputStream The output stream.
$formatter Webmozart\Console\Api\Formatter\Formatter The formatter for formatting text written to the output stream.

close() public method

Closes the output.
public close ( )

flush() public method

Forces all pending text to be written out.
public flush ( )

format() public method

public format ( $string, Style $style = null )
$style Webmozart\Console\Api\Formatter\Style

getFormatter() public method

Returns the output formatter.
public getFormatter ( ) : Webmozart\Console\Api\Formatter\Formatter
return Webmozart\Console\Api\Formatter\Formatter The output formatter.

getStream() public method

Returns the underlying stream.
public getStream ( ) : Webmozart\Console\Api\IO\OutputStream
return Webmozart\Console\Api\IO\OutputStream The output stream.

getVerbosity() public method

Returns the current verbosity level.
public getVerbosity ( ) : integer
return integer One of the verbosity constants.

isClosed() public method

Returns whether the output is closed.
public isClosed ( ) : boolean
return boolean Returns `true` if the output is closed and `false` otherwise.

isDebug() public method

Returns whether the verbosity level is {@link IO::DEBUG}.
public isDebug ( ) : boolean
return boolean Returns `true` if the verbosity level is {@link IO::DEBUG} and `false` otherwise.

isQuiet() public method

Returns whether output is suppressed completely.
public isQuiet ( ) : boolean
return boolean Returns `true` if all output is suppressed and `false` otherwise.

isVerbose() public method

Returns whether the verbosity level is {@link IO::VERBOSE} or greater.
public isVerbose ( ) : boolean
return boolean Returns `true` if the verbosity level is {@link IO::VERBOSE} or greater and `false` otherwise.

isVeryVerbose() public method

Returns whether the verbosity level is {@link IO::VERY_VERBOSE} or greater.
public isVeryVerbose ( ) : boolean
return boolean Returns `true` if the verbosity level is {@link IO::VERY_VERBOSE} or greater and `false` otherwise.

mayWrite() protected method

Returns whether an output may be written for the given flags.
protected mayWrite ( integer $flags ) : boolean
$flags integer The flags.
return boolean Returns `true` if the output may be written and `false` otherwise.

removeFormat() public method

public removeFormat ( $string )

setFormatter() public method

Sets the output formatter.
public setFormatter ( Webmozart\Console\Api\Formatter\Formatter $formatter )
$formatter Webmozart\Console\Api\Formatter\Formatter The output formatter.

setQuiet() public method

Sets whether output should be suppressed completely.
public setQuiet ( boolean $quiet )
$quiet boolean Pass `true` to suppress all output and `false` otherwise.

setStream() public method

Sets the underlying stream.
public setStream ( Webmozart\Console\Api\IO\OutputStream $stream )
$stream Webmozart\Console\Api\IO\OutputStream The output stream.

setVerbosity() public method

Sets the verbosity level of the output.
public setVerbosity ( integer $verbosity )
$verbosity integer One of the constants {@link NORMAL}, {@link VERBOSE}, {@link VERY_VERBOSE} or {@link DEBUG}. Only output with the given verbosity level or smaller will be written out.

write() public method

The string is formatted before it is written to the output stream.
public write ( string $string, integer $flags = null )
$string string The string to write.
$flags integer The flags. If one of of {@link IO::VERBOSE}, {@link IO::VERY_VERBOSE} and {@link IO::DEBUG} is passed, the output is only written if the verbosity level is the given level or higher.

writeLine() public method

The string is formatted before it is written to the output stream.
public writeLine ( string $string, integer $flags = null )
$string string The string to write. A newline is appended.
$flags integer The flags. If one of of {@link IO::VERBOSE}, {@link IO::VERY_VERBOSE} and {@link IO::DEBUG} is passed, the output is only written if the verbosity level is the given level or higher.

writeLineRaw() public method

Writes a line of text to the output stream without formatting.
public writeLineRaw ( string $string, integer $flags = null )
$string string The string to write. A newline is appended.
$flags integer The flags. If one of of {@link IO::VERBOSE}, {@link IO::VERY_VERBOSE} and {@link IO::DEBUG} is passed, the output is only written if the verbosity level is the given level or higher.

writeRaw() public method

Writes a string to the output stream without formatting.
public writeRaw ( string $string, integer $flags = null )
$string string The string to write.
$flags integer The flags. If one of of {@link IO::VERBOSE}, {@link IO::VERY_VERBOSE} and {@link IO::DEBUG} is passed, the output is only written if the verbosity level is the given level or higher.