Webmozart\Console\Api\IO\Output::writeLine PHP Method

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.
    public function writeLine($string, $flags = null)
    {
        if ($this->mayWrite($flags)) {
            $string = rtrim($string, PHP_EOL);
            $formatted = $this->formatOutput ? $this->format($string) : $this->removeFormat($string);
            $this->stream->write($formatted . PHP_EOL);
        }
    }

Usage Example

示例#1
0
 public function testWriteLineRemovesTagsIfAnsiNotSupported()
 {
     $stream = $this->getMockBuilder('Webmozart\\Console\\IO\\OutputStream\\BufferedOutputStream')->setMethods(array('supportsAnsi'))->getMock();
     $stream->expects($this->any())->method('supportsAnsi')->willReturn(false);
     $ansiFormatter = $this->getMockBuilder('Webmozart\\Console\\Formatter\\AnsiFormatter')->setMethods(array('format', 'removeFormat'))->getMock();
     $ansiFormatter->expects($this->once())->method('removeFormat')->with('<tag>text</tag>')->willReturn('text');
     $this->output->setStream($stream);
     $this->output->setFormatter($ansiFormatter);
     $this->output->writeLine('<tag>text</tag>');
     $this->assertSame('text' . PHP_EOL, $stream->fetch());
 }
All Usage Examples Of Webmozart\Console\Api\IO\Output::writeLine