@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * Add a formatter |
72 | 72 | * |
73 | 73 | * @param string $key the identifier of the formatter to add |
74 | - * @param string $formatter the class name of the formatter to add |
|
74 | + * @param FormatterInterface $formatter the class name of the formatter to add |
|
75 | 75 | * @return FormatterManager |
76 | 76 | */ |
77 | 77 | public function addFormatter($key, FormatterInterface $formatter) |
@@ -284,6 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Test to see if the stipulated format exists |
287 | + * @param string $format |
|
287 | 288 | */ |
288 | 289 | public function hasFormatter($format) |
289 | 290 | { |
@@ -10,7 +10,6 @@ discard block |
||
10 | 10 | use Consolidation\OutputFormatters\Formatters\RenderDataInterface; |
11 | 11 | use Consolidation\OutputFormatters\Options\FormatterOptions; |
12 | 12 | use Consolidation\OutputFormatters\Options\OverrideOptionsInterface; |
13 | -use Consolidation\OutputFormatters\StructuredData\MetadataInterface; |
|
14 | 13 | use Consolidation\OutputFormatters\StructuredData\RestructureInterface; |
15 | 14 | use Consolidation\OutputFormatters\Transformations\DomToArraySimplifier; |
16 | 15 | use Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface; |
@@ -19,7 +18,6 @@ discard block |
||
19 | 18 | use Symfony\Component\Console\Input\InputOption; |
20 | 19 | use Symfony\Component\Console\Output\OutputInterface; |
21 | 20 | use Consolidation\OutputFormatters\StructuredData\OriginalDataInterface; |
22 | -use Consolidation\OutputFormatters\StructuredData\ListDataFromKeys; |
|
23 | 21 | |
24 | 22 | /** |
25 | 23 | * Manage a collection of formatters; return one on request. |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | if (count($validFormats) > 1) { |
120 | 120 | // Make an input option for --format |
121 | - $description = 'Format the result data. Available formats: ' . implode(',', $validFormats); |
|
121 | + $description = 'Format the result data. Available formats: '.implode(',', $validFormats); |
|
122 | 122 | $automaticOptions[FormatterOptions::FORMAT] = new InputOption(FormatterOptions::FORMAT, '', InputOption::VALUE_REQUIRED, $description, $defaultFormat); |
123 | 123 | } |
124 | 124 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | if ($availableFields) { |
128 | 128 | $defaultFields = $options->get(FormatterOptions::DEFAULT_FIELDS, [], ''); |
129 | - $description = 'Available fields: ' . implode(', ', $this->availableFieldsList($availableFields)); |
|
129 | + $description = 'Available fields: '.implode(', ', $this->availableFieldsList($availableFields)); |
|
130 | 130 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, $description, $defaultFields); |
131 | 131 | } elseif ($dataTypeClass->implementsInterface('Consolidation\OutputFormatters\StructuredData\RestructureInterface')) { |
132 | 132 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, 'Dot notation of fields to include in output.', []); |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | protected function availableFieldsList($availableFields) |
147 | 147 | { |
148 | 148 | return array_map( |
149 | - function ($key) use ($availableFields) { |
|
150 | - return $availableFields[$key] . " ($key)"; |
|
149 | + function($key) use ($availableFields) { |
|
150 | + return $availableFields[$key]." ($key)"; |
|
151 | 151 | }, |
152 | 152 | array_keys($availableFields) |
153 | 153 | ); |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | // TODO: If the $format is the default format (not selected by the user), and |
220 | 220 | // if `convertData` switched us to unstructured data, then select a new default |
221 | 221 | // format (e.g. yaml) if the selected format cannot render the converted data. |
222 | - $formatter = $this->getFormatter((string)$format); |
|
222 | + $formatter = $this->getFormatter((string) $format); |
|
223 | 223 | |
224 | 224 | // If the data format is not applicable for the selected formatter, throw an error. |
225 | 225 | if (!is_string($structuredOutput) && !$this->isValidFormat($formatter, $structuredOutput)) { |
226 | 226 | $validFormats = $this->validFormats($structuredOutput); |
227 | - throw new InvalidFormatException((string)$format, $structuredOutput, $validFormats); |
|
227 | + throw new InvalidFormatException((string) $format, $structuredOutput, $validFormats); |
|
228 | 228 | } |
229 | 229 | if ($structuredOutput instanceof FormatterAwareInterface) { |
230 | 230 | $structuredOutput->setFormatter($formatter); |
@@ -4,10 +4,7 @@ |
||
4 | 4 | use Consolidation\OutputFormatters\Validate\ValidationInterface; |
5 | 5 | use Consolidation\OutputFormatters\Options\OverrideOptionsInterface; |
6 | 6 | use Consolidation\OutputFormatters\Options\FormatterOptions; |
7 | -use Consolidation\OutputFormatters\Validate\ValidDataTypesTrait; |
|
8 | 7 | use Symfony\Component\Console\Output\OutputInterface; |
9 | -use Consolidation\OutputFormatters\StructuredData\RestructureInterface; |
|
10 | -use Consolidation\OutputFormatters\Transformations\SimplifiedFormatterInterface; |
|
11 | 8 | use Consolidation\OutputFormatters\Transformations\StringTransformationInterface; |
12 | 9 | |
13 | 10 | /** |
@@ -36,7 +36,7 @@ |
||
36 | 36 | } |
37 | 37 | $transformed_fields = []; |
38 | 38 | foreach ($fields as $field) { |
39 | - list($machine_name,$label) = explode(' as ', $field) + [$field, preg_replace('#.*\.#', '', $field)]; |
|
39 | + list($machine_name, $label) = explode(' as ', $field) + [$field, preg_replace('#.*\.#', '', $field)]; |
|
40 | 40 | $transformed_fields[$machine_name] = $label; |
41 | 41 | } |
42 | 42 | return $transformed_fields; |