Completed
Push — master ( c47098...bd2863 )
by Shcherbak
37:44 queued 22:47
created

Select::render()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 12
nc 3
nop 0
1
<?php
2
3
  namespace Fiv\Form\Element;
4
5
  /**
6
   * Generate <select></select> html tag
7
   *
8
   * @author  Ivan Shcherbak <[email protected]>
9
   * @package Fiv\Form
10
   */
11
  class Select extends Multiple {
12
13
    /**
14
     * @return string
15
     */
16
    public function render() {
17
      $html = '<select ' . $this->getAttributesAsString() . ' >';
18
      $currentValue = $this->getValue();
19
20
      foreach ($this->options as $value => $text) {
21
        $html .= '<option'
22
          . ($currentValue == $value ? ' selected="1" ' : '')
23
          . ' value="' . $value . '"'
24
          . '>'
25
          . $text
26
          . '</option>';
27
      }
28
      $html .= '</select>';
29
      return $html;
30
    }
31
32
  }