| Conditions | 5 |
| Paths | 12 |
| Total Lines | 21 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public function select(array $data, array $attributes = [], array $options = []) |
||
| 10 | { |
||
| 11 | $dom = new SmartDOMDocument(); |
||
| 12 | if (!isset($options['selected'])) { |
||
| 13 | $options['selected'] = null; |
||
| 14 | } |
||
| 15 | $select = $dom->createElement('select'); |
||
| 16 | foreach ($attributes as $key => $val) { |
||
| 17 | $select->setAttribute($key, $val); |
||
| 18 | } |
||
| 19 | foreach ($data as $opt) { |
||
| 20 | $option = $dom->createElement('option', $opt); |
||
| 21 | $option->setAttribute('value', $opt); |
||
| 22 | if ($options['selected'] == $opt) { |
||
| 23 | $option->setAttribute('selected', 'selected'); |
||
| 24 | } |
||
| 25 | $select->appendChild($option); |
||
| 26 | } |
||
| 27 | $dom->appendChild($select); |
||
| 28 | |||
| 29 | return $dom->saveHTML(); |
||
| 30 | } |
||
| 32 |