| Conditions | 1 |
| Paths | 1 |
| Total Lines | 183 |
| Code Lines | 134 |
| 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 |
||
| 51 | public function get_examples(){ |
||
| 52 | $output = ''; |
||
| 53 | |||
| 54 | // open form |
||
| 55 | $output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
||
| 56 | |||
| 57 | $output .= aui()->input( |
||
| 58 | array( |
||
| 59 | 'type' => 'datepicker', |
||
| 60 | 'id' => 'date_example_sm', |
||
| 61 | 'size' => 'sm', |
||
| 62 | 'name' => 'date_example_sm', |
||
| 63 | 'label' => 'Date Input Label (small)', |
||
| 64 | 'help_text' => 'help text', |
||
| 65 | 'label_type' => 'top', |
||
| 66 | 'placeholder' => 'YYYY-MM-DD 00:00', |
||
| 67 | 'value' => '', |
||
| 68 | 'extra_attributes' => array( |
||
| 69 | 'data-enable-time' => 'true', |
||
| 70 | 'data-time_24hr' => 'true', |
||
| 71 | 'data-allow-input' => 'true', |
||
| 72 | ), |
||
| 73 | ) |
||
| 74 | ); |
||
| 75 | |||
| 76 | $output .= aui()->input( |
||
| 77 | array( |
||
| 78 | 'type' => 'datepicker', |
||
| 79 | 'id' => 'date_example', |
||
| 80 | //'size' => 'smx', |
||
| 81 | 'name' => 'date_example', |
||
| 82 | 'label' => 'Date Input Label', |
||
| 83 | 'help_text' => 'help text', |
||
| 84 | 'label_type' => 'top', |
||
| 85 | 'placeholder' => 'YYYY-MM-DD 00:00', |
||
| 86 | 'value' => '', |
||
| 87 | 'extra_attributes' => array( |
||
| 88 | 'data-enable-time' => 'true', |
||
| 89 | 'data-time_24hr' => 'true', |
||
| 90 | 'data-allow-input' => 'true', |
||
| 91 | ), |
||
| 92 | ) |
||
| 93 | ); |
||
| 94 | |||
| 95 | $output .= aui()->input( |
||
| 96 | array( |
||
| 97 | 'type' => 'datepicker', |
||
| 98 | 'id' => 'date_example_lg', |
||
| 99 | 'size' => 'lg', |
||
| 100 | 'name' => 'date_example_lg', |
||
| 101 | 'label' => 'Date Input Label (large)', |
||
| 102 | 'help_text' => 'help text', |
||
| 103 | 'label_type' => 'top', |
||
| 104 | 'placeholder' => 'YYYY-MM-DD 00:00', |
||
| 105 | 'value' => '', |
||
| 106 | 'extra_attributes' => array( |
||
| 107 | 'data-enable-time' => 'true', |
||
| 108 | 'data-time_24hr' => 'true', |
||
| 109 | //'data-allow-input' => 'true', |
||
| 110 | ), |
||
| 111 | ) |
||
| 112 | ); |
||
| 113 | |||
| 114 | // input example |
||
| 115 | $output .= aui()->input( |
||
| 116 | array( |
||
| 117 | 'type' => 'text', |
||
| 118 | 'id' => 'text-example', |
||
| 119 | 'size' => 'sm', |
||
| 120 | //'clear_icon' => true, |
||
| 121 | 'name' => 'text-example', |
||
| 122 | 'placeholder' => 'text placeholder', |
||
| 123 | 'title' => 'Text input example', |
||
| 124 | 'value' => '', |
||
| 125 | 'required' => false, |
||
| 126 | 'help_text' => 'help text', |
||
| 127 | 'label' => 'Text input example label', |
||
| 128 | 'label_type' => 'top' |
||
| 129 | ) |
||
| 130 | ); |
||
| 131 | |||
| 132 | $output .= aui()->input( |
||
| 133 | array( |
||
| 134 | 'type' => 'search', |
||
| 135 | 'id' => 'text-example', |
||
| 136 | 'size' => 'sm', |
||
| 137 | //'clear_icon' => true, |
||
| 138 | 'name' => 'text-example', |
||
| 139 | 'placeholder' => 'text placeholder', |
||
| 140 | 'title' => 'Text input example', |
||
| 141 | 'value' => '', |
||
| 142 | 'required' => false, |
||
| 143 | 'help_text' => 'help text', |
||
| 144 | 'label' => 'Text input example label', |
||
| 145 | 'label_type' => 'top' |
||
| 146 | ) |
||
| 147 | ); |
||
| 148 | |||
| 149 | // input example |
||
| 150 | $output .= aui()->input( |
||
| 151 | array( |
||
| 152 | 'type' => 'url', |
||
| 153 | 'id' => 'text-example2', |
||
| 154 | 'name' => 'text-example', |
||
| 155 | 'placeholder' => 'url placeholder', |
||
| 156 | 'title' => 'Text input example', |
||
| 157 | 'value' => '', |
||
| 158 | 'required' => false, |
||
| 159 | 'help_text' => 'help text', |
||
| 160 | 'label' => 'Text input example label' |
||
| 161 | ) |
||
| 162 | ); |
||
| 163 | |||
| 164 | // checkbox example |
||
| 165 | $output .= aui()->input( |
||
| 166 | array( |
||
| 167 | 'type' => 'checkbox', |
||
| 168 | 'id' => 'checkbox-example', |
||
| 169 | 'name' => 'checkbox-example', |
||
| 170 | 'placeholder' => 'checkbox-example', |
||
| 171 | 'title' => 'Checkbox example', |
||
| 172 | 'value' => '1', |
||
| 173 | 'checked' => true, |
||
| 174 | 'required' => false, |
||
| 175 | 'help_text' => 'help text', |
||
| 176 | 'label' => 'Checkbox checked' |
||
| 177 | ) |
||
| 178 | ); |
||
| 179 | |||
| 180 | // checkbox example |
||
| 181 | $output .= aui()->input( |
||
| 182 | array( |
||
| 183 | 'type' => 'checkbox', |
||
| 184 | 'id' => 'checkbox-example2', |
||
| 185 | 'name' => 'checkbox-example2', |
||
| 186 | 'placeholder' => 'checkbox-example', |
||
| 187 | 'title' => 'Checkbox example', |
||
| 188 | 'value' => '1', |
||
| 189 | 'checked' => false, |
||
| 190 | 'required' => false, |
||
| 191 | 'help_text' => 'help text', |
||
| 192 | 'label' => 'Checkbox un-checked' |
||
| 193 | ) |
||
| 194 | ); |
||
| 195 | |||
| 196 | // switch example |
||
| 197 | $output .= aui()->input( |
||
| 198 | array( |
||
| 199 | 'type' => 'checkbox', |
||
| 200 | 'id' => 'switch-example', |
||
| 201 | 'name' => 'switch-example', |
||
| 202 | 'placeholder' => 'checkbox-example', |
||
| 203 | 'title' => 'Switch example', |
||
| 204 | 'value' => '1', |
||
| 205 | 'checked' => true, |
||
| 206 | 'switch' => true, |
||
| 207 | 'required' => false, |
||
| 208 | 'help_text' => 'help text', |
||
| 209 | 'label' => 'Switch on' |
||
| 210 | ) |
||
| 211 | ); |
||
| 212 | |||
| 213 | // switch example |
||
| 214 | $output .= aui()->input( |
||
| 215 | array( |
||
| 216 | 'type' => 'checkbox', |
||
| 217 | 'id' => 'switch-example2', |
||
| 218 | 'name' => 'switch-example2', |
||
| 219 | 'placeholder' => 'checkbox-example', |
||
| 220 | 'title' => 'Switch example', |
||
| 221 | 'value' => '1', |
||
| 222 | 'checked' => false, |
||
| 223 | 'switch' => true, |
||
| 224 | 'required' => false, |
||
| 225 | 'help_text' => 'help text', |
||
| 226 | 'label' => 'Switch off' |
||
| 227 | ) |
||
| 228 | ); |
||
| 229 | |||
| 230 | // close form |
||
| 231 | $output .= "</form>"; |
||
| 232 | |||
| 233 | return $output; |
||
| 234 | } |
||
| 237 | new AyeCode_UI_Plugin(); |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.