1 | <?php |
||
19 | class XmlRenderer implements RendererInterface |
||
20 | { |
||
21 | const NAME_ROOT = 'table'; |
||
22 | const NAME_ROW = 'row'; |
||
23 | |||
24 | private $headers; |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function render(OutputInterface $output, array $rows) |
||
47 | |||
48 | private function appendRows(DOMElement $parent, array $rows) |
||
64 | |||
65 | /** |
||
66 | * @param DOMElement $row |
||
67 | * @param array $fields |
||
68 | */ |
||
69 | private function appendRowFields(DOMElement $row, array $fields) |
||
78 | |||
79 | /** |
||
80 | * @param DOMElement $parent |
||
81 | * @param array $headers |
||
82 | */ |
||
83 | private function appendHeaders(DOMElement $parent, array $headers = null) |
||
97 | |||
98 | /** |
||
99 | * create a DOMElement containing the data |
||
100 | * |
||
101 | * @param DOMDocument $doc |
||
102 | * @param string $key |
||
103 | * @param string $value |
||
104 | * |
||
105 | * @return DOMElement |
||
106 | */ |
||
107 | private function createField(DOMDocument $doc, $key, $value) |
||
121 | |||
122 | /** |
||
123 | * @param string $string |
||
124 | * |
||
125 | * @return string valid XML element name |
||
126 | * |
||
127 | * @throws DOMException if no valid XML Name can be generated |
||
128 | * @throws RuntimeException if character encoding is not US-ASCII or UTF-8 |
||
129 | */ |
||
130 | private function getName($string) |
||
147 | |||
148 | /** |
||
149 | * @param int $index zero-based |
||
150 | * @param mixed $default |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | private function getHeader($index, $default = null) |
||
162 | |||
163 | /** |
||
164 | * @param array $rows |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | private function setHeadersFrom(array $rows) |
||
176 | } |
||
177 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.