1 | <?php |
||
28 | class FormatterOptions |
||
29 | { |
||
30 | /** var array */ |
||
31 | protected $configurationData = []; |
||
32 | /** var array */ |
||
33 | protected $options = []; |
||
34 | /** var InputInterface */ |
||
35 | protected $input; |
||
36 | |||
37 | const FORMAT = 'format'; |
||
38 | const DEFAULT_FORMAT = 'default-format'; |
||
39 | const TABLE_STYLE = 'table-style'; |
||
40 | const LIST_ORIENTATION = 'list-orientation'; |
||
41 | const FIELDS = 'fields'; |
||
42 | const FIELD = 'field'; |
||
43 | const INCLUDE_FIELD_LABELS = 'include-field-labels'; |
||
44 | const ROW_LABELS = 'row-labels'; |
||
45 | const FIELD_LABELS = 'field-labels'; |
||
46 | const DEFAULT_FIELDS = 'default-fields'; |
||
47 | const DEFAULT_STRING_FIELD = 'default-string-field'; |
||
48 | const DELIMITER = 'delimiter'; |
||
49 | const TERMINAL_WIDTH = 'width'; |
||
50 | |||
51 | /** |
||
52 | * Create a new FormatterOptions with the configuration data and the |
||
53 | * user-specified options for this request. |
||
54 | * |
||
55 | * @see FormatterOptions::setInput() |
||
56 | * @param array $configurationData |
||
57 | * @param array $options |
||
58 | */ |
||
59 | public function __construct($configurationData = [], $options = []) |
||
64 | |||
65 | /** |
||
66 | * Create a new FormatterOptions object with new configuration data (provided), |
||
67 | * and the same options data as this instance. |
||
68 | * |
||
69 | * @param array $configurationData |
||
70 | * @return FormatterOptions |
||
71 | */ |
||
72 | public function override($configurationData) |
||
80 | |||
81 | public function setTableStyle($style) |
||
85 | |||
86 | public function setIncludeFieldLables($includFieldLables) |
||
90 | |||
91 | public function setListOrientation($listOrientation) |
||
95 | |||
96 | public function setRowLabels($rowLabels) |
||
100 | |||
101 | public function setDefaultFields($fields) |
||
105 | |||
106 | public function setFieldLabels($fieldLabels) |
||
110 | |||
111 | public function setDefaultStringField($defaultStringField) |
||
115 | |||
116 | public function setWidth($width) |
||
120 | |||
121 | /** |
||
122 | * Get a formatter option |
||
123 | * |
||
124 | * @param string $key |
||
125 | * @param array $defaults |
||
126 | * @param mixed $default |
||
127 | * @return mixed |
||
128 | */ |
||
129 | public function get($key, $defaults = [], $default = false) |
||
134 | |||
135 | /** |
||
136 | * Return the XmlSchema to use with --format=xml for data types that support |
||
137 | * that. This is used when an array needs to be converted into xml. |
||
138 | * |
||
139 | * @return XmlSchema |
||
140 | */ |
||
141 | public function getXmlSchema() |
||
145 | |||
146 | /** |
||
147 | * Determine the format that was requested by the caller. |
||
148 | * |
||
149 | * @param array $defaults |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getFormat($defaults = []) |
||
156 | |||
157 | /** |
||
158 | * Look up a key, and return its raw value. |
||
159 | * |
||
160 | * @param string $key |
||
161 | * @param array $defaults |
||
162 | * @param mixed $default |
||
163 | * @return mixed |
||
164 | */ |
||
165 | protected function fetch($key, $defaults = [], $default = false) |
||
171 | |||
172 | /** |
||
173 | * Reduce provided defaults to the single item identified by '$key', |
||
174 | * if it exists, or an empty array otherwise. |
||
175 | * |
||
176 | * @param string $key |
||
177 | * @param array $defaults |
||
178 | * @return array |
||
179 | */ |
||
180 | protected function defaultsForKey($key, $defaults, $default = false) |
||
187 | |||
188 | /** |
||
189 | * Look up all of the items associated with the provided defaults. |
||
190 | * |
||
191 | * @param array $defaults |
||
192 | * @return array |
||
193 | */ |
||
194 | protected function fetchRawValues($defaults = []) |
||
203 | |||
204 | /** |
||
205 | * Given the raw value for a specific key, do any type conversion |
||
206 | * (e.g. from a textual list to an array) needed for the data. |
||
207 | * |
||
208 | * @param string $key |
||
209 | * @param mixed $value |
||
210 | * @return mixed |
||
211 | */ |
||
212 | protected function parse($key, $value) |
||
220 | |||
221 | /** |
||
222 | * Convert from a textual list to an array |
||
223 | * |
||
224 | * @param string $value |
||
225 | * @return array |
||
226 | */ |
||
227 | public function parsePropertyList($value) |
||
231 | |||
232 | /** |
||
233 | * Given a specific key, return the class method name of the |
||
234 | * parsing method for data stored under this key. |
||
235 | * |
||
236 | * @param string $key |
||
237 | * @return string |
||
238 | */ |
||
239 | protected function getOptionFormat($key) |
||
250 | |||
251 | /** |
||
252 | * Change the configuration data for this formatter options object. |
||
253 | * |
||
254 | * @param array $configurationData |
||
255 | * @return FormatterOptions |
||
256 | */ |
||
257 | public function setConfigurationData($configurationData) |
||
262 | |||
263 | /** |
||
264 | * Change one configuration value for this formatter option. |
||
265 | * |
||
266 | * @param string $key |
||
267 | * @param mixed $value |
||
268 | * @return FormetterOptions |
||
269 | */ |
||
270 | protected function setConfigurationValue($key, $value) |
||
275 | |||
276 | /** |
||
277 | * Change one configuration value for this formatter option, but only |
||
278 | * if it does not already have a value set. |
||
279 | * |
||
280 | * @param string $key |
||
281 | * @param mixed $value |
||
282 | * @return FormetterOptions |
||
283 | */ |
||
284 | public function setConfigurationDefault($key, $value) |
||
291 | |||
292 | /** |
||
293 | * Return a reference to the configuration data for this object. |
||
294 | * |
||
295 | * @return array |
||
296 | */ |
||
297 | public function getConfigurationData() |
||
301 | |||
302 | /** |
||
303 | * Set all of the options that were specified by the user for this request. |
||
304 | * |
||
305 | * @param array $options |
||
306 | * @return FormatterOptions |
||
307 | */ |
||
308 | public function setOptions($options) |
||
313 | |||
314 | /** |
||
315 | * Change one option value specified by the user for this request. |
||
316 | * |
||
317 | * @param string $key |
||
318 | * @param mixed $value |
||
319 | * @return FormatterOptions |
||
320 | */ |
||
321 | public function setOption($key, $value) |
||
326 | |||
327 | /** |
||
328 | * Return a reference to the user-specified options for this request. |
||
329 | * |
||
330 | * @return array |
||
331 | */ |
||
332 | public function getOptions() |
||
336 | |||
337 | /** |
||
338 | * Provide a Symfony Console InputInterface containing the user-specified |
||
339 | * options for this request. |
||
340 | * |
||
341 | * @param InputInterface $input |
||
342 | * @return type |
||
343 | */ |
||
344 | public function setInput(InputInterface $input) |
||
348 | |||
349 | /** |
||
350 | * Return all of the options from the provided $defaults array that |
||
351 | * exist in our InputInterface object. |
||
352 | * |
||
353 | * @param array $defaults |
||
354 | * @return array |
||
355 | */ |
||
356 | public function getInputOptions($defaults) |
||
372 | } |
||
373 |