Total Complexity | 14 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
3 | class Nip_Form_Renderer_Elements_Select extends \Nip\Form\Renderer\Elements\AbstractElementRenderer |
||
4 | { |
||
5 | /** |
||
6 | * @return string |
||
7 | */ |
||
8 | public function generateElement() |
||
14 | } |
||
15 | |||
16 | public function renderOptions($options = false) |
||
17 | { |
||
18 | $options = $options ? $options : $this->getElement()->getOptions(); |
||
19 | $return = ''; |
||
20 | |||
21 | $selectedValue = $this->getElement()->getValue(); |
||
|
|||
22 | |||
23 | foreach ($options as $value=>$atribs) { |
||
24 | if (is_string($value) && !isset($atribs['label'])) { |
||
25 | $return .= '<optgroup label="' . $value . '">'; |
||
26 | $return .= $this->renderOptions($atribs); |
||
27 | $return .= '</optgroup>'; |
||
28 | } else { |
||
29 | $return .= '<option'; |
||
30 | |||
31 | $label = $atribs['label']; |
||
32 | unset($atribs['label']); |
||
33 | |||
34 | $atribs['value'] = $value; |
||
35 | if ($this->isOptionSelected($value, $selectedValue)) { |
||
36 | $atribs['selected'] = 'selected'; |
||
37 | } |
||
38 | |||
39 | foreach ($atribs as $name=>$value) { |
||
40 | $return .= ' ' . $name . '="' . $value . '"'; |
||
41 | } |
||
42 | $return .= '>' . $label . '</option>'; |
||
43 | } |
||
44 | } |
||
45 | return $return; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param $value |
||
50 | * @param $selectedValue |
||
51 | * @return bool |
||
52 | */ |
||
53 | protected function isOptionSelected($value, $selectedValue): bool |
||
66 | } |
||
67 | } |
||
68 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.