@@ -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\SimplifyToStringInterface; |
| 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; |
@@ -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 | } |
| 132 | 132 | elseif ($dataTypeClass->implementsInterface(RestructureInterface::class)) { |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | protected function availableFieldsList($availableFields) |
| 148 | 148 | { |
| 149 | 149 | return array_map( |
| 150 | - function ($key) use ($availableFields) { |
|
| 151 | - return $availableFields[$key] . " ($key)"; |
|
| 150 | + function($key) use ($availableFields) { |
|
| 151 | + return $availableFields[$key]." ($key)"; |
|
| 152 | 152 | }, |
| 153 | 153 | array_keys($availableFields) |
| 154 | 154 | ); |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function write(OutputInterface $output, $format, $structuredOutput, FormatterOptions $options) |
| 214 | 214 | { |
| 215 | - $formatter = $this->getFormatter((string)$format); |
|
| 215 | + $formatter = $this->getFormatter((string) $format); |
|
| 216 | 216 | if (!is_string($structuredOutput) && !$this->isValidFormat($formatter, $structuredOutput)) { |
| 217 | 217 | $validFormats = $this->validFormats($structuredOutput); |
| 218 | - throw new InvalidFormatException((string)$format, $structuredOutput, $validFormats); |
|
| 218 | + throw new InvalidFormatException((string) $format, $structuredOutput, $validFormats); |
|
| 219 | 219 | } |
| 220 | 220 | if ($structuredOutput instanceof FormatterAwareInterface) { |
| 221 | 221 | $structuredOutput->setFormatter($formatter); |
@@ -128,8 +128,7 @@ |
||
| 128 | 128 | $defaultFields = $options->get(FormatterOptions::DEFAULT_FIELDS, [], ''); |
| 129 | 129 | $description = 'Available fields: ' . implode(', ', $this->availableFieldsList($availableFields)); |
| 130 | 130 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, $description, $defaultFields); |
| 131 | - } |
|
| 132 | - elseif ($dataTypeClass->implementsInterface(RestructureInterface::class)) { |
|
| 131 | + } elseif ($dataTypeClass->implementsInterface(RestructureInterface::class)) { |
|
| 133 | 132 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, 'Dot notation of fields to include in output.', []); |
| 134 | 133 | } |
| 135 | 134 | |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | { |
| 55 | 55 | $result = ''; |
| 56 | 56 | $iterator = $this->getIterator(); |
| 57 | - while($iterator->valid()) { |
|
| 57 | + while ($iterator->valid()) { |
|
| 58 | 58 | $simplifiedRow = $this->simplifyRow($iterator->current()); |
| 59 | 59 | if (isset($simplifiedRow)) { |
| 60 | 60 | $result .= "$simplifiedRow\n"; |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | foreach ($item as $key => $value) { |
| 42 | 42 | $result->set($key, $value); |
| 43 | 43 | } |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | $result->set($label, $data->get($key)); |
| 47 | 46 | } |
| 48 | 47 | } |