Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Output / Printer / StreamOutputPrinter.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Output\Printer;
12
13 use Behat\Testwork\Output\Printer\Factory\OutputFactory;
14 use Symfony\Component\Console\Output\OutputInterface;
15
16 /**
17  * @author Wouter J <wouter@wouterj.nl>
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
20 class StreamOutputPrinter implements OutputPrinter
21 {
22     /**
23      * @var OutputInterface
24      */
25     private $output;
26     /**
27      * @var OutputFactory
28      */
29     private $outputFactory;
30
31     public function __construct(OutputFactory $outputFactory)
32     {
33         $this->outputFactory = $outputFactory;
34     }
35
36     /**
37      * @return OutputFactory
38      */
39     protected function getOutputFactory()
40     {
41         return $this->outputFactory;
42     }
43
44     /**
45      * {@inheritdoc}
46      */
47     public function setOutputPath($path)
48     {
49         $this->outputFactory->setOutputPath($path);
50         $this->flush();
51     }
52
53     /**
54      * {@inheritdoc}
55      */
56     public function getOutputPath()
57     {
58         return $this->outputFactory->getOutputPath();
59     }
60
61     /**
62      * {@inheritdoc}
63      */
64     public function setOutputStyles(array $styles)
65     {
66         $this->outputFactory->setOutputStyles($styles);
67         $this->flush();
68     }
69
70     /**
71      * {@inheritdoc}
72      */
73     public function getOutputStyles()
74     {
75         return $this->outputFactory->getOutputStyles();
76     }
77
78     /**
79      * {@inheritdoc}
80      */
81     public function setOutputDecorated($decorated)
82     {
83         $this->outputFactory->setOutputDecorated($decorated);
84         $this->flush();
85     }
86
87     /**
88      * {@inheritdoc}
89      */
90     public function isOutputDecorated()
91     {
92         return $this->outputFactory->isOutputDecorated();
93     }
94
95     /**
96      * {@inheritdoc}
97      */
98     public function setOutputVerbosity($level)
99     {
100         $this->outputFactory->setOutputVerbosity($level);
101         $this->flush();
102     }
103
104     /**
105      * {@inheritdoc}
106      */
107     public function getOutputVerbosity()
108     {
109         return $this->outputFactory->getOutputVerbosity();
110     }
111
112     /**
113      * {@inheritdoc}
114      */
115     public function write($messages)
116     {
117         $this->getWritingStream()->write($messages, false);
118     }
119
120     /**
121      * {@inheritdoc}
122      */
123     public function writeln($messages = '')
124     {
125         $this->getWritingStream()->write($messages, true);
126     }
127
128     /**
129      * {@inheritdoc}
130      */
131     public function flush()
132     {
133         $this->output = null;
134     }
135
136     /**
137      * Returns output instance, prepared to write.
138      *
139      * @return OutputInterface
140      */
141     final protected function getWritingStream()
142     {
143         if (null === $this->output) {
144             $this->output = $this->outputFactory->createOutput();
145         }
146
147         return $this->output;
148     }
149 }