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 | |||
50 | /** |
||
51 | * Create a new FormatterOptions with the configuration data and the |
||
52 | * user-specified options for this request. |
||
53 | * |
||
54 | * @see FormatterOptions::setInput() |
||
55 | * @param array $configurationData |
||
56 | * @param array $options |
||
57 | */ |
||
58 | public function __construct($configurationData = [], $options = []) |
||
63 | |||
64 | /** |
||
65 | * Create a new FormatterOptions object with new configuration data (provided), |
||
66 | * and the same options data as this instance. |
||
67 | * |
||
68 | * @param array $configurationData |
||
69 | * @return FormatterOptions |
||
70 | */ |
||
71 | public function override($configurationData) |
||
79 | |||
80 | public function setTableStyle($style) |
||
84 | |||
85 | public function setIncludeFieldLables($includFieldLables) |
||
89 | |||
90 | public function setListOrientation($listOrientation) |
||
94 | |||
95 | public function setRowLabels($rowLabels) |
||
99 | |||
100 | public function setDefaultFields($fields) |
||
104 | |||
105 | public function setFieldLabels($fieldLabels) |
||
109 | |||
110 | public function setDefaultStringField($defaultStringField) |
||
114 | |||
115 | /** |
||
116 | * Get a formatter option |
||
117 | * |
||
118 | * @param string $key |
||
119 | * @param array $defaults |
||
120 | * @param mixed $default |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function get($key, $defaults = [], $default = false) |
||
128 | |||
129 | /** |
||
130 | * Return the XmlSchema to use with --format=xml for data types that support |
||
131 | * that. This is used when an array needs to be converted into xml. |
||
132 | * |
||
133 | * @return XmlSchema |
||
134 | */ |
||
135 | public function getXmlSchema() |
||
139 | |||
140 | /** |
||
141 | * Determine the format that was requested by the caller. |
||
142 | * |
||
143 | * @param array $defaults |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getFormat($defaults = []) |
||
150 | |||
151 | /** |
||
152 | * Look up a key, and return its raw value. |
||
153 | * |
||
154 | * @param string $key |
||
155 | * @param array $defaults |
||
156 | * @param mixed $default |
||
157 | * @return mixed |
||
158 | */ |
||
159 | protected function fetch($key, $defaults = [], $default = false) |
||
165 | |||
166 | /** |
||
167 | * Reduce provided defaults to the single item identified by '$key', |
||
168 | * if it exists, or an empty array otherwise. |
||
169 | * |
||
170 | * @param string $key |
||
171 | * @param array $defaults |
||
172 | * @return array |
||
173 | */ |
||
174 | protected function defaultsForKey($key, $defaults, $default = false) |
||
181 | |||
182 | /** |
||
183 | * Look up all of the items associated with the provided defaults. |
||
184 | * |
||
185 | * @param array $defaults |
||
186 | * @return array |
||
187 | */ |
||
188 | protected function fetchRawValues($defaults = []) |
||
197 | |||
198 | /** |
||
199 | * Given the raw value for a specific key, do any type conversion |
||
200 | * (e.g. from a textual list to an array) needed for the data. |
||
201 | * |
||
202 | * @param string $key |
||
203 | * @param mixed $value |
||
204 | * @return mixed |
||
205 | */ |
||
206 | protected function parse($key, $value) |
||
214 | |||
215 | /** |
||
216 | * Convert from a textual list to an array |
||
217 | * |
||
218 | * @param string $value |
||
219 | * @return array |
||
220 | */ |
||
221 | public function parsePropertyList($value) |
||
225 | |||
226 | /** |
||
227 | * Given a specific key, return the class method name of the |
||
228 | * parsing method for data stored under this key. |
||
229 | * |
||
230 | * @param string $key |
||
231 | * @return string |
||
232 | */ |
||
233 | protected function getOptionFormat($key) |
||
244 | |||
245 | /** |
||
246 | * Change the configuration data for this formatter options object. |
||
247 | * |
||
248 | * @param array $configurationData |
||
249 | * @return FormatterOptions |
||
250 | */ |
||
251 | public function setConfigurationData($configurationData) |
||
256 | |||
257 | /** |
||
258 | * Change one configuration value for this formatter option. |
||
259 | * |
||
260 | * @param string $key |
||
261 | * @param mixed $value |
||
262 | * @return FormetterOptions |
||
263 | */ |
||
264 | protected function setConfigurationValue($key, $value) |
||
269 | |||
270 | /** |
||
271 | * Change one configuration value for this formatter option, but only |
||
272 | * if it does not already have a value set. |
||
273 | * |
||
274 | * @param string $key |
||
275 | * @param mixed $value |
||
276 | * @return FormetterOptions |
||
277 | */ |
||
278 | public function setConfigurationDefault($key, $value) |
||
285 | |||
286 | /** |
||
287 | * Return a reference to the configuration data for this object. |
||
288 | * |
||
289 | * @return array |
||
290 | */ |
||
291 | public function getConfigurationData() |
||
295 | |||
296 | /** |
||
297 | * Set all of the options that were specified by the user for this request. |
||
298 | * |
||
299 | * @param array $options |
||
300 | * @return FormatterOptions |
||
301 | */ |
||
302 | public function setOptions($options) |
||
307 | |||
308 | /** |
||
309 | * Change one option value specified by the user for this request. |
||
310 | * |
||
311 | * @param string $key |
||
312 | * @param mixed $value |
||
313 | * @return FormatterOptions |
||
314 | */ |
||
315 | public function setOption($key, $value) |
||
320 | |||
321 | /** |
||
322 | * Return a reference to the user-specified options for this request. |
||
323 | * |
||
324 | * @return array |
||
325 | */ |
||
326 | public function getOptions() |
||
330 | |||
331 | /** |
||
332 | * Provide a Symfony Console InputInterface containing the user-specified |
||
333 | * options for this request. |
||
334 | * |
||
335 | * @param InputInterface $input |
||
336 | * @return type |
||
337 | */ |
||
338 | public function setInput(InputInterface $input) |
||
342 | |||
343 | /** |
||
344 | * Return all of the options from the provided $defaults array that |
||
345 | * exist in our InputInterface object. |
||
346 | * |
||
347 | * @param array $defaults |
||
348 | * @return array |
||
349 | */ |
||
350 | public function getInputOptions($defaults) |
||
366 | } |
||
367 |