1 | <?php |
||
15 | class IndentedOutput implements OutputInterface |
||
16 | { |
||
17 | const INDENT_WIDTH = 2; |
||
18 | |||
19 | const DEFAULT_INDENT_LEVEL = 3; |
||
20 | const DEFAULT_INDENT_CHARACTER = ' '; |
||
21 | |||
22 | /** |
||
23 | * @var string String being appended to the message |
||
24 | */ |
||
25 | private $indentation; |
||
26 | |||
27 | /** |
||
28 | * @var OutputInterface |
||
29 | */ |
||
30 | private $decoratedOutput; |
||
31 | |||
32 | /** |
||
33 | * IndentedOutput constructor. |
||
34 | * |
||
35 | * @param OutputInterface $decoratedOutput |
||
36 | * @param int $indentLevel |
||
37 | * @param string $indentCharacter |
||
38 | */ |
||
39 | public function __construct( |
||
47 | |||
48 | /** |
||
49 | * Writes a message to the output. |
||
50 | * |
||
51 | * @param string|array $messages The message as an array of lines or a single string |
||
52 | * @param bool $newline Whether to add a newline |
||
53 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
54 | */ |
||
55 | public function write($messages, $newline = false, $options = 0) |
||
61 | |||
62 | /** |
||
63 | * Writes a message to the output and adds a newline at the end. |
||
64 | * |
||
65 | * @param string|array $messages The message as an array of lines of a single string |
||
66 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
||
67 | */ |
||
68 | public function writeln($messages, $options = 0) |
||
74 | |||
75 | /** |
||
76 | * Sets the verbosity of the output. |
||
77 | * |
||
78 | * @param int $level The level of verbosity (one of the VERBOSITY constants) |
||
79 | */ |
||
80 | public function setVerbosity($level) |
||
84 | |||
85 | /** |
||
86 | * Gets the current verbosity of the output. |
||
87 | * |
||
88 | * @return int The current level of verbosity (one of the VERBOSITY constants) |
||
89 | */ |
||
90 | public function getVerbosity() |
||
94 | |||
95 | /** |
||
96 | * Returns whether verbosity is quiet (-q). |
||
97 | * |
||
98 | * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise |
||
99 | */ |
||
100 | public function isQuiet() |
||
104 | |||
105 | /** |
||
106 | * Returns whether verbosity is verbose (-v). |
||
107 | * |
||
108 | * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise |
||
109 | */ |
||
110 | public function isVerbose() |
||
114 | |||
115 | /** |
||
116 | * Returns whether verbosity is very verbose (-vv). |
||
117 | * |
||
118 | * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise |
||
119 | */ |
||
120 | public function isVeryVerbose() |
||
124 | |||
125 | /** |
||
126 | * Returns whether verbosity is debug (-vvv). |
||
127 | * |
||
128 | * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise |
||
129 | */ |
||
130 | public function isDebug() |
||
134 | |||
135 | /** |
||
136 | * Sets the decorated flag. |
||
137 | * |
||
138 | * @param bool $decorated Whether to decorate the messages |
||
139 | */ |
||
140 | public function setDecorated($decorated) |
||
144 | |||
145 | /** |
||
146 | * Gets the decorated flag. |
||
147 | * |
||
148 | * @return bool true if the output will decorate messages, false otherwise |
||
149 | */ |
||
150 | public function isDecorated() |
||
154 | |||
155 | /** |
||
156 | * Sets output formatter. |
||
157 | * |
||
158 | * @param \Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter |
||
159 | */ |
||
160 | public function setFormatter(\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter) |
||
164 | |||
165 | /** |
||
166 | * Returns current output formatter instance. |
||
167 | * |
||
168 | * @return \Symfony\Component\Console\Formatter\OutputFormatterInterface |
||
169 | */ |
||
170 | public function getFormatter() |
||
174 | |||
175 | /** |
||
176 | * Prepend message with padding |
||
177 | * |
||
178 | * @param $messages |
||
179 | * |
||
180 | * @return array|string |
||
181 | */ |
||
182 | private function addIndentationToMessages($messages) |
||
197 | } |