MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
StreamOutput.php
Ir para a documentação deste ficheiro.
1<?php
2
4
5/*
6 * This file is part of the Symfony framework.
7 *
8 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
9 *
10 * This source file is subject to the MIT license that is bundled
11 * with this source code in the file LICENSE.
12 */
13
27class StreamOutput extends Output
28{
29 protected $stream;
30
40 public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null)
41 {
42 if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
43 throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
44 }
45
46 $this->stream = $stream;
47
48 if (null === $decorated) {
50 }
51
52 parent::__construct($verbosity, $decorated);
53 }
54
60 public function getStream()
61 {
62 return $this->stream;
63 }
64
73 public function doWrite($message, $newline)
74 {
75 if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) {
76 // @codeCoverageIgnoreStart
77 // should never happen
78 throw new \RuntimeException('Unable to write output.');
79 // @codeCoverageIgnoreEnd
80 }
81
82 flush();
83 }
84
95 protected function hasColorSupport()
96 {
97 // @codeCoverageIgnoreStart
98 if (DIRECTORY_SEPARATOR == '\\') {
99 return false !== getenv('ANSICON');
100 } else {
101 return function_exists('posix_isatty') && @posix_isatty($this->stream);
102 }
103 // @codeCoverageIgnoreEnd
104 }
105}
__construct($stream, $verbosity=self::VERBOSITY_NORMAL, $decorated=null)