pho\Console\Console::write PHP Method

write() public method

Outputs a single line, replacing all occurrences of the newline character in the string with PHP_EOL for cross-platform support.
public write ( string $string )
$string string The string to print
    public function write($string)
    {
        fwrite($this->stream, str_replace("\n", PHP_EOL, $string));
    }

Usage Example

Exemplo n.º 1
0
        context('when reporter not found', function () {
            before(function () {
                $this->console = new Console(['-r', 'unkown'], 'php://output');
                $this->console->parseArguments();
            });
            it('throw pho\\Exception\\ReporterNotFoundException exception', function () {
                expect(function () {
                    $this->console->getReporterClass();
                })->toThrow('pho\\Exception\\ReporterNotFoundException');
            });
        });
    });
    context('write', function () {
        it('prints the text to the terminal', function () {
            $write = function () {
                $console = new Console([], 'php://output');
                $console->write('test');
            };
            expect($write)->toPrint('test');
        });
    });
    context('writeLn', function () {
        it('prints the text, followed by a newline, to the terminal', function () {
            $writeLn = function () {
                $console = new Console([], 'php://output');
                $console->writeLn('test');
            };
            expect($writeLn)->toPrint('test' . PHP_EOL);
        });
    });
});