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 | * @param string $string |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function filter($string) |
||
112 | |||
113 | /** |
||
114 | * @param array $diff |
||
115 | * @param bool $newline |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | private function buildOutput(array $diff, $newline = false) |
||
149 | |||
150 | /** |
||
151 | * Writes a message to the output and adds a newline at the end. |
||
152 | * |
||
153 | * @param string|array $messages The message as an array of lines of a single string |
||
154 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered |
||
155 | * the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
156 | */ |
||
157 | public function writeln($messages, $options = 0) |
||
161 | |||
162 | /** |
||
163 | * Sets the verbosity of the output. |
||
164 | * |
||
165 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
166 | */ |
||
167 | public function setVerbosity($level) |
||
171 | |||
172 | /** |
||
173 | * Gets the current verbosity of the output. |
||
174 | * |
||
175 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
176 | */ |
||
177 | public function getVerbosity() |
||
181 | |||
182 | /** |
||
183 | * Returns whether verbosity is quiet (-q). |
||
184 | * |
||
185 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
186 | */ |
||
187 | public function isQuiet() |
||
191 | |||
192 | /** |
||
193 | * Returns whether verbosity is verbose (-v). |
||
194 | * |
||
195 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
196 | */ |
||
197 | public function isVerbose() |
||
201 | |||
202 | /** |
||
203 | * Returns whether verbosity is very verbose (-vv). |
||
204 | * |
||
205 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
206 | */ |
||
207 | public function isVeryVerbose() |
||
211 | |||
212 | /** |
||
213 | * Returns whether verbosity is debug (-vvv). |
||
214 | * |
||
215 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
216 | */ |
||
217 | public function isDebug() |
||
221 | |||
222 | /** |
||
223 | * Sets the decorated flag. |
||
224 | * |
||
225 | * @param bool $decorated Whether to decorate the messages |
||
226 | */ |
||
227 | public function setDecorated($decorated) |
||
231 | |||
232 | /** |
||
233 | * Gets the decorated flag. |
||
234 | * |
||
235 | * @return bool true if the output will decorate messages, false otherwise |
||
236 | */ |
||
237 | public function isDecorated() |
||
241 | |||
242 | /** |
||
243 | * Sets output formatter. |
||
244 | * |
||
245 | * @param OutputFormatterInterface $formatter |
||
246 | */ |
||
247 | public function setFormatter(OutputFormatterInterface $formatter) |
||
251 | |||
252 | /** |
||
253 | * Returns current output formatter instance. |
||
254 | * |
||
255 | * @return OutputFormatterInterface |
||
256 | */ |
||
257 | public function getFormatter() |
||
261 | |||
262 | /** |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function isTrim() |
||
269 | |||
270 | /** |
||
271 | * Should we wrap the input or not, if this is set to false, it will trim each line |
||
272 | * |
||
273 | * @param bool $trim |
||
274 | * |
||
275 | * @return $this |
||
276 | */ |
||
277 | public function setTrim($trim) |
||
282 | } |
||
283 |