@@ -34,6 +34,9 @@ discard block |
||
34 | 34 | $this->addXmlChildren($dom, $element, $elementName, $structuredData); |
35 | 35 | } |
36 | 36 | |
37 | + /** |
|
38 | + * @param \DOMElement $xmlParent |
|
39 | + */ |
|
37 | 40 | protected function addXmlChildren(\DOMDocument $dom, $xmlParent, $elementName, $structuredData) |
38 | 41 | { |
39 | 42 | foreach ($structuredData as $key => $value) { |
@@ -52,6 +55,9 @@ discard block |
||
52 | 55 | $this->addXmlData($dom, $xmlParent, $elementName, $value); |
53 | 56 | } |
54 | 57 | |
58 | + /** |
|
59 | + * @param string $childElementName |
|
60 | + */ |
|
55 | 61 | protected function determineElementName($key, $childElementName, $value) |
56 | 62 | { |
57 | 63 | if (is_numeric($key)) { |
@@ -58,7 +58,7 @@ |
||
58 | 58 | return $childElementName; |
59 | 59 | } |
60 | 60 | if (is_object($value)) { |
61 | - $value = (array)$value; |
|
61 | + $value = (array) $value; |
|
62 | 62 | } |
63 | 63 | if (!is_array($value)) { |
64 | 64 | return $key; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | return $this->calculateColumnWidths( |
54 | 54 | $rows, |
55 | - function ($cell) { |
|
55 | + function($cell) { |
|
56 | 56 | return strlen($cell); |
57 | 57 | } |
58 | 58 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | return $this->calculateColumnWidths( |
67 | 67 | $rows, |
68 | - function ($cell) { |
|
68 | + function($cell) { |
|
69 | 69 | return static::longestWordLength($cell); |
70 | 70 | } |
71 | 71 | ); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | protected static function longestWordLength($str) |
134 | 134 | { |
135 | 135 | $words = preg_split('#[ /-]#', $str); |
136 | - $lengths = array_map(function ($s) { |
|
136 | + $lengths = array_map(function($s) { |
|
137 | 137 | return strlen($s); |
138 | 138 | }, $words); |
139 | 139 | return max($lengths); |
@@ -188,7 +188,7 @@ |
||
188 | 188 | { |
189 | 189 | return array_reduce( |
190 | 190 | $widths, |
191 | - function ($carry, $item) { |
|
191 | + function($carry, $item) { |
|
192 | 192 | return $carry + $item; |
193 | 193 | } |
194 | 194 | ); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | 'sections' => '\Consolidation\OutputFormatters\Formatters\SectionsFormatter', |
49 | 49 | ]; |
50 | 50 | if (class_exists('Symfony\Component\VarDumper\Dumper\CliDumper')) { |
51 | - $defaultFormatters['var_dump'] = '\Consolidation\OutputFormatters\Formatters\VarDumpFormatter'; |
|
51 | + $defaultFormatters['var_dump'] = '\Consolidation\OutputFormatters\Formatters\VarDumpFormatter'; |
|
52 | 52 | } |
53 | 53 | foreach ($defaultFormatters as $id => $formatterClassname) { |
54 | 54 | $formatter = new $formatterClassname; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | if (count($validFormats) > 1) { |
121 | 121 | // Make an input option for --format |
122 | - $description = 'Format the result data. Available formats: ' . implode(',', $validFormats); |
|
122 | + $description = 'Format the result data. Available formats: '.implode(',', $validFormats); |
|
123 | 123 | $automaticOptions[FormatterOptions::FORMAT] = new InputOption(FormatterOptions::FORMAT, '', InputOption::VALUE_REQUIRED, $description, $defaultFormat); |
124 | 124 | } |
125 | 125 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | if ($availableFields) { |
129 | 129 | $defaultFields = $options->get(FormatterOptions::DEFAULT_FIELDS, [], ''); |
130 | - $description = 'Available fields: ' . implode(', ', $this->availableFieldsList($availableFields)); |
|
130 | + $description = 'Available fields: '.implode(', ', $this->availableFieldsList($availableFields)); |
|
131 | 131 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, $description, $defaultFields); |
132 | 132 | } elseif ($dataTypeClass->implementsInterface('Consolidation\OutputFormatters\StructuredData\RestructureInterface')) { |
133 | 133 | $automaticOptions[FormatterOptions::FIELDS] = new InputOption(FormatterOptions::FIELDS, '', InputOption::VALUE_REQUIRED, 'Limit output to only the listed elements. Name top-level elements by key, e.g. "--fields=name,date", or use dot notation to select a nested element, e.g. "--fields=a.b.c as example".', []); |
@@ -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 | ); |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | // TODO: If the $format is the default format (not selected by the user), and |
221 | 221 | // if `convertData` switched us to unstructured data, then select a new default |
222 | 222 | // format (e.g. yaml) if the selected format cannot render the converted data. |
223 | - $formatter = $this->getFormatter((string)$format); |
|
223 | + $formatter = $this->getFormatter((string) $format); |
|
224 | 224 | |
225 | 225 | // If the data format is not applicable for the selected formatter, throw an error. |
226 | 226 | if (!is_string($structuredOutput) && !$this->isValidFormat($formatter, $structuredOutput)) { |
227 | 227 | $validFormats = $this->validFormats($structuredOutput); |
228 | - throw new InvalidFormatException((string)$format, $structuredOutput, $validFormats); |
|
228 | + throw new InvalidFormatException((string) $format, $structuredOutput, $validFormats); |
|
229 | 229 | } |
230 | 230 | if ($structuredOutput instanceof FormatterAwareInterface) { |
231 | 231 | $structuredOutput->setFormatter($formatter); |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * transformation object. First, though, remove any metadata items. |
22 | 22 | * |
23 | 23 | * @param FormatterOptions $options Options that affect output formatting. |
24 | - * @return Consolidation\OutputFormatters\Transformations\TableTransformation |
|
24 | + * @return \Consolidation\OutputFormatters\Transformations\TableTransformation |
|
25 | 25 | */ |
26 | 26 | public function restructure(FormatterOptions $options) |
27 | 27 | { |
@@ -59,6 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Right-justify the cell data. |
62 | + * @param string $key |
|
62 | 63 | */ |
63 | 64 | protected function justifyCellData($key, $cellData) |
64 | 65 | { |
@@ -76,6 +77,7 @@ discard block |
||
76 | 77 | |
77 | 78 | /** |
78 | 79 | * Determine if this is a column that should be formatted. |
80 | + * @param string $key |
|
79 | 81 | */ |
80 | 82 | protected function isRenderedColumn($key) |
81 | 83 | { |
@@ -102,6 +104,7 @@ discard block |
||
102 | 104 | * This formatter only works with columns whose columns are strings. |
103 | 105 | * To use this formatter for another purpose, override this method |
104 | 106 | * to ensure that the cell data is a string before it is formatted. |
107 | + * @return double |
|
105 | 108 | */ |
106 | 109 | protected function convertCellDataToString($cellData) |
107 | 110 | { |
@@ -110,6 +113,7 @@ discard block |
||
110 | 113 | |
111 | 114 | /** |
112 | 115 | * Get the cached column width for the provided key. |
116 | + * @return integer |
|
113 | 117 | */ |
114 | 118 | protected function columnWidth($key) |
115 | 119 | { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Consolidation\OutputFormatters\StructuredData; |
3 | 3 | |
4 | 4 | use Consolidation\OutputFormatters\Options\FormatterOptions; |
5 | - |
|
6 | 5 | use Consolidation\OutputFormatters\Formatters\FormatterAwareInterface; |
7 | 6 | use Consolidation\OutputFormatters\Formatters\FormatterAwareTrait; |
8 | 7 |
@@ -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; |