| Total Complexity | 68 |
| Total Lines | 281 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
Complex classes like Form often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Form, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 28 | class Form implements interfaceForm |
||
| 29 | { |
||
| 30 | |||
| 31 | /** |
||
| 32 | * open form |
||
| 33 | * |
||
| 34 | * This method return the form element <form... |
||
| 35 | * |
||
| 36 | * @param array(id, name, class, onsubmit, method, action, files, style) |
||
|
|
|||
| 37 | * |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | public static function open($params = array()) |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * closed the form |
||
| 60 | * |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public static function close() |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * textBox |
||
| 70 | * |
||
| 71 | * This method creates a textarea element |
||
| 72 | * |
||
| 73 | * @param array(id, name, class, onclick, columns, rows, disabled, placeholder, style, value) |
||
| 74 | * |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | public static function textBox($params = array()) |
||
| 78 | { |
||
| 79 | |||
| 80 | if (!is_array($params)) { |
||
| 81 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 82 | } |
||
| 83 | $o = '<textarea'; |
||
| 84 | $o .= self::param_mix($params); |
||
| 85 | $o .= (isset($params['cols'])) ? " cols='{$params['cols']}'" : ''; |
||
| 86 | $o .= (isset($params['rows'])) ? " rows='{$params['rows']}'" : ''; |
||
| 87 | $o .= (isset($params['maxlength'])) ? " maxlength='{$params['maxlength']}'" : ''; |
||
| 88 | $o .= (isset($params['required'])) ? " required='required'" : ''; |
||
| 89 | $o .= '>'; |
||
| 90 | $o .= (isset($params['value'])) ? $params['value'] : ''; |
||
| 91 | $o .= "</textarea>\n"; |
||
| 92 | return $o; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * input |
||
| 97 | * |
||
| 98 | * This method returns a input text element. |
||
| 99 | * |
||
| 100 | * @param array(id, name, class, onclick, value, length, width, disable,placeholder) |
||
| 101 | * |
||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | public static function input($params = array()) |
||
| 105 | { |
||
| 106 | |||
| 107 | if (!is_array($params)) { |
||
| 108 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 109 | } |
||
| 110 | |||
| 111 | $o = '<input '; |
||
| 112 | $o .= self::param_mix($params); |
||
| 113 | $o .= (isset($params['onkeypress'])) ? " onkeypress='{$params['onkeypress']}'" : ''; |
||
| 114 | $o .= (isset($params['length'])) ? " maxlength='{$params['length']}'" : ''; |
||
| 115 | $o .= (isset($params['width'])) ? " style='width:{$params['width']}px;'" : ''; |
||
| 116 | $o .= (isset($params['accept'])) ? " accept='{$params['accept']}'" : ''; |
||
| 117 | $o .= (isset($params['maxlength'])) ? " maxlength='{$params['maxlength']}'" : ''; |
||
| 118 | $o .= (isset($params['minlength'])) ? " minlength='{$params['minlength']}'" : ''; |
||
| 119 | $o .= (isset($params['autocomplete'])) ? " autocomplete='{$params['autocomplete']}'" : ''; |
||
| 120 | $o .= (isset($params['autofocus'])) ? " autofocus" : ''; |
||
| 121 | $o .= " />\n"; |
||
| 122 | return $o; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * select |
||
| 127 | * |
||
| 128 | * This method returns a select html element. |
||
| 129 | * It can be given a param called value which then will be preselected |
||
| 130 | * data has to be array(k=>v) |
||
| 131 | * |
||
| 132 | * @param array(id, name, class, onclick, disabled) |
||
| 133 | * |
||
| 134 | * @return string |
||
| 135 | */ |
||
| 136 | public static function select($params = array()) |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * checkboxMulti |
||
| 165 | * |
||
| 166 | * This method returns multiple checkbox elements in order given in an array |
||
| 167 | * For checking of checkbox pass checked |
||
| 168 | * Each checkbox should look like array(0=>array('id'=>'1', 'name'=>'cb[]', 'value'=>'x', 'label'=>'label_text' )) |
||
| 169 | * |
||
| 170 | * @param array(array(id, name, value, class, checked, disabled)) |
||
| 171 | * |
||
| 172 | * @return string |
||
| 173 | */ |
||
| 174 | public static function checkbox($params = array()) |
||
| 175 | { |
||
| 176 | |||
| 177 | if (!is_array($params)) { |
||
| 178 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 179 | } |
||
| 180 | $o = ''; |
||
| 181 | $x = 0; |
||
| 182 | foreach ($params as $k => $v) { |
||
| 183 | $v['id'] = (isset($v['id'])) ? $v['id'] : "cb_id_{$x}_" . rand(1000, 9999); |
||
| 184 | $o .= "<input type='checkbox'"; |
||
| 185 | $o .= self::param_mix($params); |
||
| 186 | $o .= (isset($v['checked'])) ? " checked='checked'" : ''; |
||
| 187 | $o .= (isset($v['disabled'])) ? " disabled='{$v['disabled']}'" : ''; |
||
| 188 | $o .= " />\n"; |
||
| 189 | $o .= (isset($v['label'])) ? "<label for='{$v['id']}'>{$v['label']}</label> " : ''; |
||
| 190 | $x++; |
||
| 191 | } |
||
| 192 | |||
| 193 | return $o; |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * radioMulti |
||
| 198 | * |
||
| 199 | * This method returns radio elements in order given in an array |
||
| 200 | * For selection pass checked |
||
| 201 | * Each radio should look like array(0=>array('id'=>'1', 'name'=>'rd[]', 'value'=>'x', 'label'=>'label_text' )) |
||
| 202 | * |
||
| 203 | * @param array(array(id, name, value, class, checked, disabled, label)) |
||
| 204 | * |
||
| 205 | * @return string |
||
| 206 | */ |
||
| 207 | public static function radio($params = array()) |
||
| 208 | { |
||
| 209 | |||
| 210 | if (!is_array($params)) { |
||
| 211 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 212 | } |
||
| 213 | |||
| 214 | $o = ''; |
||
| 215 | $x = 0; |
||
| 216 | foreach ($params as $k => $v) { |
||
| 217 | $v['id'] = (isset($v['id'])) ? $v['id'] : "rd_id_{$x}_" . rand(1000, 9999); |
||
| 218 | $o .= "<input type='radio'"; |
||
| 219 | $o .= self::param_mix($params); |
||
| 220 | $o .= (isset($v['checked'])) ? " checked='checked'" : ''; |
||
| 221 | $o .= (isset($v['disabled'])) ? " disabled='{$v['disabled']}'" : ''; |
||
| 222 | $o .= " />\n"; |
||
| 223 | $o .= (isset($v['label'])) ? "<label for='{$v['id']}'>{$v['label']}</label> " : ''; |
||
| 224 | $x++; |
||
| 225 | } |
||
| 226 | |||
| 227 | return $o; |
||
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * This method returns a button element given the params for settings |
||
| 232 | * |
||
| 233 | * @param array(id, name, class, onclick, value, disabled) |
||
| 234 | * |
||
| 235 | * @return string |
||
| 236 | */ |
||
| 237 | public static function button($params = array()) |
||
| 238 | { |
||
| 239 | |||
| 240 | if (!is_array($params)) { |
||
| 241 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 242 | } |
||
| 243 | |||
| 244 | $o = "<button type='submit'"; |
||
| 245 | $o .= self::param_mix($params); |
||
| 246 | $o .= (isset($params['onclick'])) ? " onclick='{$params['onclick']}'" : ''; |
||
| 247 | $o .= ">"; |
||
| 248 | $o .= (isset($params['class'])) ? "<i class='fa {$params['iclass']}'></i> " : ''; |
||
| 249 | $o .= "</button>\n"; |
||
| 250 | return $o; |
||
| 251 | } |
||
| 252 | |||
| 253 | /** |
||
| 254 | * This method returns a submit button element given the params for settings |
||
| 255 | * |
||
| 256 | * @param array(id, name, class, onclick, value, disabled) |
||
| 257 | * |
||
| 258 | * @return string |
||
| 259 | */ |
||
| 260 | public static function submit($params = array()) |
||
| 261 | { |
||
| 262 | |||
| 263 | if (!is_array($params)) { |
||
| 264 | throw new \InvalidArgumentException("Arguments is not a Array" . print_r($params, true)); |
||
| 265 | } |
||
| 266 | |||
| 267 | $o = '<input type="submit"'; |
||
| 268 | $o .= self::param_mix($params); |
||
| 269 | $o .= (isset($params['onclick'])) ? " onclick='{$params['onclick']}'" : ''; |
||
| 270 | $o .= " />\n"; |
||
| 271 | return $o; |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * |
||
| 276 | * @since 1.0.6 |
||
| 277 | * |
||
| 278 | * @param [ 'for' => 'exemplo-title' ], ['title' => 'Example Title' ]; |
||
| 279 | * |
||
| 280 | * @return string |
||
| 281 | */ |
||
| 282 | |||
| 283 | private static function param_mix($params = array()) { |
||
| 297 | |||
| 298 | } |
||
| 299 | public static function label($params = array()) |
||
| 300 | { |
||
| 301 | $o = "<label"; |
||
| 309 | } |
||
| 310 | |||
| 311 | } |
||
| 312 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths