Select::render()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

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