1 | <?php |
||
29 | class DiffConsoleOutput implements ConsoleOutputInterface |
||
30 | { |
||
31 | /** @var string[] */ |
||
32 | private $buffer = []; |
||
33 | /** @var ConsoleDiff */ |
||
34 | private $diff; |
||
35 | /** @var TerminalInterface */ |
||
36 | private $terminal; |
||
37 | /** @var ConsoleOutputInterface */ |
||
38 | private $output; |
||
39 | /** @var Wrapper */ |
||
40 | private $wrapper; |
||
41 | /** @var bool */ |
||
42 | private $trim = false; |
||
43 | |||
44 | /** |
||
45 | * Constructor. |
||
46 | * |
||
47 | * @param ConsoleOutputInterface $output |
||
48 | * @param TerminalInterface $terminal |
||
49 | * @param Wrapper $wrapper |
||
50 | */ |
||
51 | public function __construct( |
||
61 | |||
62 | /** |
||
63 | * Sets information about the terminal |
||
64 | * |
||
65 | * @param TerminalInterface $terminal |
||
66 | */ |
||
67 | public function setTerminal(TerminalInterface $terminal) |
||
72 | |||
73 | /** |
||
74 | * @return TerminalInterface |
||
75 | */ |
||
76 | public function getTerminal() |
||
80 | |||
81 | /** |
||
82 | * @param string|array $messages The message as an array of lines or a single string |
||
83 | * @param bool $newline Whether to add a newline |
||
84 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
85 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
86 | */ |
||
87 | public function write($messages, $newline = false, $options = 0) |
||
92 | |||
93 | /** |
||
94 | * @param string|string[] $messages The message as an array of lines or a single string |
||
95 | * @param bool $newline Whether to add a newline |
||
96 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
97 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
98 | */ |
||
99 | public function reWrite($messages, $newline = false, $options = 0) |
||
122 | |||
123 | /** |
||
124 | * @param array $diff |
||
125 | * @param bool $newline |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | private function buildOutput(array $diff, $newline = false) |
||
159 | |||
160 | /** |
||
161 | * Gets the OutputInterface for errors. |
||
162 | * |
||
163 | * @return OutputInterface |
||
164 | */ |
||
165 | public function getErrorOutput() |
||
169 | |||
170 | /** |
||
171 | * Sets the OutputInterface used for errors. |
||
172 | * |
||
173 | * @param OutputInterface $error |
||
174 | */ |
||
175 | public function setErrorOutput(OutputInterface $error) |
||
179 | |||
180 | /** |
||
181 | * Writes a message to the output and adds a newline at the end. |
||
182 | * |
||
183 | * @param string|array $messages The message as an array of lines of a single string |
||
184 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
185 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
186 | */ |
||
187 | public function writeln($messages, $options = 0) |
||
191 | |||
192 | /** |
||
193 | * Sets the verbosity of the output. |
||
194 | * |
||
195 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
196 | */ |
||
197 | public function setVerbosity($level) |
||
201 | |||
202 | /** |
||
203 | * Gets the current verbosity of the output. |
||
204 | * |
||
205 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
206 | */ |
||
207 | public function getVerbosity() |
||
211 | |||
212 | /** |
||
213 | * Returns whether verbosity is quiet (-q). |
||
214 | * |
||
215 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
216 | */ |
||
217 | public function isQuiet() |
||
221 | |||
222 | /** |
||
223 | * Returns whether verbosity is verbose (-v). |
||
224 | * |
||
225 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
226 | */ |
||
227 | public function isVerbose() |
||
231 | |||
232 | /** |
||
233 | * Returns whether verbosity is very verbose (-vv). |
||
234 | * |
||
235 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
236 | */ |
||
237 | public function isVeryVerbose() |
||
241 | |||
242 | /** |
||
243 | * Returns whether verbosity is debug (-vvv). |
||
244 | * |
||
245 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
246 | */ |
||
247 | public function isDebug() |
||
251 | |||
252 | /** |
||
253 | * Sets the decorated flag. |
||
254 | * |
||
255 | * @param bool $decorated Whether to decorate the messages |
||
256 | */ |
||
257 | public function setDecorated($decorated) |
||
261 | |||
262 | /** |
||
263 | * Gets the decorated flag. |
||
264 | * |
||
265 | * @return bool true if the output will decorate messages, false otherwise |
||
266 | */ |
||
267 | public function isDecorated() |
||
271 | |||
272 | /** |
||
273 | * Sets output formatter. |
||
274 | * |
||
275 | * @param OutputFormatterInterface $formatter |
||
276 | */ |
||
277 | public function setFormatter(OutputFormatterInterface $formatter) |
||
281 | |||
282 | /** |
||
283 | * Returns current output formatter instance. |
||
284 | * |
||
285 | * @return OutputFormatterInterface |
||
286 | */ |
||
287 | public function getFormatter() |
||
291 | |||
292 | /** |
||
293 | * @return bool |
||
294 | */ |
||
295 | public function isTrim() |
||
299 | |||
300 | /** |
||
301 | * Should we wrap the input or not, if this is set to false, it will trim each line |
||
302 | * |
||
303 | * @param bool $trim |
||
304 | * |
||
305 | * @return $this |
||
306 | */ |
||
307 | public function setTrim($trim) |
||
312 | } |
||
313 |