1 | <?php |
||
28 | class DiffConsoleOutput implements OutputInterface |
||
29 | { |
||
30 | /** @var string[] */ |
||
31 | private $buffer = []; |
||
32 | /** @var ConsoleDiff */ |
||
33 | private $diff; |
||
34 | /** @var TerminalInterface */ |
||
35 | private $terminal; |
||
36 | /** @var OutputInterface */ |
||
37 | private $output; |
||
38 | /** @var Wrapper */ |
||
39 | private $wrapper; |
||
40 | /** @var bool */ |
||
41 | private $trim = false; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param OutputInterface $output |
||
47 | * @param TerminalInterface $terminal |
||
48 | * @param Wrapper $wrapper |
||
49 | */ |
||
50 | public function __construct( |
||
60 | |||
61 | /** |
||
62 | * @param string|array $messages The message as an array of lines or a single string |
||
63 | * @param bool $newline Whether to add a newline |
||
64 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
65 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
66 | */ |
||
67 | public function write($messages, $newline = false, $options = 0) |
||
72 | |||
73 | /** |
||
74 | * @param string|string[] $messages The message as an array of lines or a single string |
||
75 | * @param bool $newline Whether to add a newline |
||
76 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
77 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
78 | */ |
||
79 | public function reWrite($messages, $newline = false, $options = 0) |
||
102 | |||
103 | /** |
||
104 | * @return TerminalInterface |
||
105 | */ |
||
106 | public function getTerminal() |
||
110 | |||
111 | /** |
||
112 | * @param array $diff |
||
113 | * @param bool $newline |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | private function buildOutput(array $diff, $newline = false) |
||
147 | |||
148 | /** |
||
149 | * Writes a message to the output and adds a newline at the end. |
||
150 | * |
||
151 | * @param string|array $messages The message as an array of lines of a single string |
||
152 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
153 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
154 | */ |
||
155 | public function writeln($messages, $options = 0) |
||
159 | |||
160 | /** |
||
161 | * Sets the verbosity of the output. |
||
162 | * |
||
163 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
164 | */ |
||
165 | public function setVerbosity($level) |
||
169 | |||
170 | /** |
||
171 | * Gets the current verbosity of the output. |
||
172 | * |
||
173 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
174 | */ |
||
175 | public function getVerbosity() |
||
179 | |||
180 | /** |
||
181 | * Returns whether verbosity is quiet (-q). |
||
182 | * |
||
183 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
184 | */ |
||
185 | public function isQuiet() |
||
189 | |||
190 | /** |
||
191 | * Returns whether verbosity is verbose (-v). |
||
192 | * |
||
193 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
194 | */ |
||
195 | public function isVerbose() |
||
199 | |||
200 | /** |
||
201 | * Returns whether verbosity is very verbose (-vv). |
||
202 | * |
||
203 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
204 | */ |
||
205 | public function isVeryVerbose() |
||
209 | |||
210 | /** |
||
211 | * Returns whether verbosity is debug (-vvv). |
||
212 | * |
||
213 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
214 | */ |
||
215 | public function isDebug() |
||
219 | |||
220 | /** |
||
221 | * Sets the decorated flag. |
||
222 | * |
||
223 | * @param bool $decorated Whether to decorate the messages |
||
224 | */ |
||
225 | public function setDecorated($decorated) |
||
229 | |||
230 | /** |
||
231 | * Gets the decorated flag. |
||
232 | * |
||
233 | * @return bool true if the output will decorate messages, false otherwise |
||
234 | */ |
||
235 | public function isDecorated() |
||
239 | |||
240 | /** |
||
241 | * Sets output formatter. |
||
242 | * |
||
243 | * @param OutputFormatterInterface $formatter |
||
244 | */ |
||
245 | public function setFormatter(OutputFormatterInterface $formatter) |
||
249 | |||
250 | /** |
||
251 | * Returns current output formatter instance. |
||
252 | * |
||
253 | * @return OutputFormatterInterface |
||
254 | */ |
||
255 | public function getFormatter() |
||
259 | |||
260 | /** |
||
261 | * @return bool |
||
262 | */ |
||
263 | public function isTrim() |
||
267 | |||
268 | /** |
||
269 | * Should we wrap the input or not, if this is set to false, it will trim each line |
||
270 | * |
||
271 | * @param bool $trim |
||
272 | * |
||
273 | * @return $this |
||
274 | */ |
||
275 | public function setTrim($trim) |
||
280 | } |
||
281 |