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 | * @param string|array $messages The message as an array of lines or a single string |
||
64 | * @param bool $newline Whether to add a newline |
||
65 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
66 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
67 | */ |
||
68 | public function write($messages, $newline = false, $options = 0) |
||
73 | |||
74 | /** |
||
75 | * @param string|string[] $messages The message as an array of lines or a single string |
||
76 | * @param bool $newline Whether to add a newline |
||
77 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
78 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
79 | */ |
||
80 | public function reWrite($messages, $newline = false, $options = 0) |
||
103 | |||
104 | /** |
||
105 | * @param array $diff |
||
106 | * @param bool $newline |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | private function buildOutput(array $diff, $newline = false) |
||
140 | |||
141 | /** |
||
142 | * Gets the OutputInterface for errors. |
||
143 | * |
||
144 | * @return OutputInterface |
||
145 | */ |
||
146 | public function getErrorOutput() |
||
150 | |||
151 | /** |
||
152 | * Sets the OutputInterface used for errors. |
||
153 | * |
||
154 | * @param OutputInterface $error |
||
155 | */ |
||
156 | public function setErrorOutput(OutputInterface $error) |
||
160 | |||
161 | /** |
||
162 | * Writes a message to the output and adds a newline at the end. |
||
163 | * |
||
164 | * @param string|array $messages The message as an array of lines of a single string |
||
165 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
166 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
167 | */ |
||
168 | public function writeln($messages, $options = 0) |
||
172 | |||
173 | /** |
||
174 | * Sets the verbosity of the output. |
||
175 | * |
||
176 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
177 | */ |
||
178 | public function setVerbosity($level) |
||
182 | |||
183 | /** |
||
184 | * Gets the current verbosity of the output. |
||
185 | * |
||
186 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
187 | */ |
||
188 | public function getVerbosity() |
||
192 | |||
193 | /** |
||
194 | * Returns whether verbosity is quiet (-q). |
||
195 | * |
||
196 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
197 | */ |
||
198 | public function isQuiet() |
||
202 | |||
203 | /** |
||
204 | * Returns whether verbosity is verbose (-v). |
||
205 | * |
||
206 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
207 | */ |
||
208 | public function isVerbose() |
||
212 | |||
213 | /** |
||
214 | * Returns whether verbosity is very verbose (-vv). |
||
215 | * |
||
216 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
217 | */ |
||
218 | public function isVeryVerbose() |
||
222 | |||
223 | /** |
||
224 | * Returns whether verbosity is debug (-vvv). |
||
225 | * |
||
226 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
227 | */ |
||
228 | public function isDebug() |
||
232 | |||
233 | /** |
||
234 | * Sets the decorated flag. |
||
235 | * |
||
236 | * @param bool $decorated Whether to decorate the messages |
||
237 | */ |
||
238 | public function setDecorated($decorated) |
||
242 | |||
243 | /** |
||
244 | * Gets the decorated flag. |
||
245 | * |
||
246 | * @return bool true if the output will decorate messages, false otherwise |
||
247 | */ |
||
248 | public function isDecorated() |
||
252 | |||
253 | /** |
||
254 | * Sets output formatter. |
||
255 | * |
||
256 | * @param OutputFormatterInterface $formatter |
||
257 | */ |
||
258 | public function setFormatter(OutputFormatterInterface $formatter) |
||
262 | |||
263 | /** |
||
264 | * Returns current output formatter instance. |
||
265 | * |
||
266 | * @return OutputFormatterInterface |
||
267 | */ |
||
268 | public function getFormatter() |
||
272 | |||
273 | /** |
||
274 | * @return bool |
||
275 | */ |
||
276 | public function isTrim() |
||
280 | |||
281 | /** |
||
282 | * Should we wrap the input or not, if this is set to false, it will trim each line |
||
283 | * |
||
284 | * @param bool $trim |
||
285 | * |
||
286 | * @return $this |
||
287 | */ |
||
288 | public function setTrim($trim) |
||
293 | } |
||
294 |