| Total Complexity | 12 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 2 | class Nip_Form_Renderer_Elements_Select extends Nip_Form_Renderer_Elements_Abstract |
||
|
|
|||
| 3 | { |
||
| 4 | public function generateElement() |
||
| 10 | } |
||
| 11 | |||
| 12 | public function renderOptions($options = false) |
||
| 13 | { |
||
| 14 | $options = $options ? $options : $this->getElement()->getOptions(); |
||
| 15 | $return = ''; |
||
| 16 | foreach ($options as $value=>$atribs) { |
||
| 17 | if (is_string($value) && !isset($atribs['label'])) { |
||
| 18 | $return .= '<optgroup label="' . $value . '">'; |
||
| 19 | $return .= $this->renderOptions($atribs); |
||
| 20 | $return .= '</optgroup>'; |
||
| 21 | } else { |
||
| 22 | $return .= '<option'; |
||
| 23 | |||
| 24 | $label = $atribs['label']; |
||
| 25 | unset($atribs['label']); |
||
| 26 | |||
| 27 | $atribs['value'] = $value; |
||
| 28 | $selectedValue = $this->getElement()->getValue(); |
||
| 29 | if ($selectedValue === 0 or $value === 0) { |
||
| 30 | if ($value === $selectedValue) { |
||
| 31 | $atribs['selected'] = 'selected'; |
||
| 32 | } |
||
| 33 | } elseif ($this->getElement()->getValue() == $value) { |
||
| 34 | $atribs['selected'] = 'selected'; |
||
| 35 | } |
||
| 36 | |||
| 37 | foreach ($atribs as $name=>$value) { |
||
| 38 | $return .= ' ' . $name . '="' . $value . '"'; |
||
| 39 | } |
||
| 40 | $return .= '>' . $label . '</option>'; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | return $return; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function getElementAttribs() |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.