4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Testwork\Output\Printer;
13 use Behat\Testwork\Output\Printer\Factory\OutputFactory;
14 use Symfony\Component\Console\Output\OutputInterface;
17 * @author Wouter J <wouter@wouterj.nl>
18 * @author Konstantin Kudryashov <ever.zet@gmail.com>
20 class StreamOutputPrinter implements OutputPrinter
23 * @var OutputInterface
29 private $outputFactory;
31 public function __construct(OutputFactory $outputFactory)
33 $this->outputFactory = $outputFactory;
37 * @return OutputFactory
39 protected function getOutputFactory()
41 return $this->outputFactory;
47 public function setOutputPath($path)
49 $this->outputFactory->setOutputPath($path);
56 public function getOutputPath()
58 return $this->outputFactory->getOutputPath();
64 public function setOutputStyles(array $styles)
66 $this->outputFactory->setOutputStyles($styles);
73 public function getOutputStyles()
75 return $this->outputFactory->getOutputStyles();
81 public function setOutputDecorated($decorated)
83 $this->outputFactory->setOutputDecorated($decorated);
90 public function isOutputDecorated()
92 return $this->outputFactory->isOutputDecorated();
98 public function setOutputVerbosity($level)
100 $this->outputFactory->setOutputVerbosity($level);
107 public function getOutputVerbosity()
109 return $this->outputFactory->getOutputVerbosity();
115 public function write($messages)
117 $this->getWritingStream()->write($messages, false);
123 public function writeln($messages = '')
125 $this->getWritingStream()->write($messages, true);
131 public function flush()
133 $this->output = null;
137 * Returns output instance, prepared to write.
139 * @return OutputInterface
141 final protected function getWritingStream()
143 if (null === $this->output) {
144 $this->output = $this->outputFactory->createOutput();
147 return $this->output;