Conditions | 11 |
Paths | 98 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
48 | protected function getInput() |
||
49 | { |
||
50 | $html = array(); |
||
51 | |||
52 | // Initialize some field attributes. |
||
53 | $class = $this->element['class'] ? ' class="checkboxes ' . (string) $this->element['class'] . '"' : ' class="checkboxes"'; |
||
54 | $checkedOptions = explode(',', (string) $this->element['checked']); |
||
55 | |||
56 | // Start the checkbox field output. |
||
57 | $html[] = '<fieldset id="' . $this->id . '"' . $class . '>'; |
||
58 | |||
59 | // Get the field options. |
||
60 | $options = $this->getOptions(); |
||
61 | |||
62 | // Build the checkbox field output. |
||
63 | $html[] = '<ul>'; |
||
64 | |||
65 | foreach ($options as $i => $option) |
||
66 | { |
||
67 | // Initialize some option attributes. |
||
68 | if (!isset($this->value) || empty($this->value)) |
||
69 | { |
||
70 | $checked = (in_array((string) $option->value, (array) $checkedOptions) ? ' checked="checked"' : ''); |
||
71 | } |
||
72 | else |
||
73 | { |
||
74 | $value = !is_array($this->value) ? explode(',', $this->value) : $this->value; |
||
75 | $checked = (in_array((string) $option->value, $value) ? ' checked="checked"' : ''); |
||
76 | } |
||
77 | |||
78 | $class = !empty($option->class) ? ' class="' . $option->class . '"' : ''; |
||
79 | $disabled = !empty($option->disable) ? ' disabled="disabled"' : ''; |
||
80 | |||
81 | // Initialize some JavaScript option attributes. |
||
82 | $onclick = !empty($option->onclick) ? ' onclick="' . $option->onclick . '"' : ''; |
||
83 | |||
84 | $html[] = '<li>'; |
||
85 | $html[] = '<input type="checkbox" id="' . $this->id . $i . '" name="' . $this->name . '"' . ' value="' |
||
86 | . htmlspecialchars($option->value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $class . $onclick . $disabled . '/>'; |
||
87 | |||
88 | $html[] = '<label for="' . $this->id . $i . '"' . $class . '>' . Text::_($option->text) . '</label>'; |
||
89 | $html[] = '</li>'; |
||
90 | } |
||
91 | |||
92 | $html[] = '</ul>'; |
||
93 | |||
94 | // End the checkbox field output. |
||
95 | $html[] = '</fieldset>'; |
||
96 | |||
97 | return implode($html); |
||
98 | } |
||
99 | |||
139 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.