| Conditions | 6 |
| Paths | 10 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function __construct(?string $name = null, ?string $value = null, ?iterable $options = null) |
||
| 13 | { |
||
| 14 | parent::__construct(); |
||
| 15 | |||
| 16 | $this->name($name); |
||
| 17 | |||
| 18 | $this->selected($value); |
||
| 19 | |||
| 20 | if(!empty($options)) { |
||
| 21 | $isIndexed = array_keys($options) === range(0, count($options) - 1); |
||
| 22 | |||
| 23 | $opt = ''; |
||
| 24 | foreach($options as $key => $val) { |
||
| 25 | $selected = ($isIndexed ? $val : $key) == $value ? ' selected="selected"' : ''; |
||
| 26 | $opt .= '<option value="' . ($isIndexed ? $val : $key) . '"' . $selected . '>' . $val . '</option>'; |
||
| 27 | } |
||
| 28 | |||
| 29 | $this->value($opt); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 53 | } |