| Conditions | 2 |
| Paths | 2 |
| Total Lines | 164 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 35 | public function boot() |
||
| 36 | { |
||
| 37 | $style = Config::get('form.style'); |
||
| 38 | |||
| 39 | if ($style == null) { |
||
| 40 | $style = 'bootstrap4'; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @parem string $name |
||
| 45 | * @parem string $label |
||
| 46 | * @parem mixed $default |
||
| 47 | * @parem bool $required |
||
| 48 | * @parem array $attributes |
||
| 49 | */ |
||
| 50 | Form::component('hText', 'form::'.$style.'.horizon.text', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 51 | /** |
||
| 52 | * @parem string $name |
||
| 53 | * @parem string $label |
||
| 54 | * @parem mixed $default |
||
| 55 | * @parem bool $required |
||
| 56 | * @parem array $attributes |
||
| 57 | */ |
||
| 58 | Form::component('hEmail', 'form::'.$style.'.horizon.email', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @parem string $name |
||
| 62 | * @parem string $label |
||
| 63 | * @parem bool $required |
||
| 64 | * @parem array $attributes |
||
| 65 | */ |
||
| 66 | Form::component('hPassword', 'form::'.$style.'.horizon.password', ['name', 'label', 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @parem string $name |
||
| 70 | * @parem string $label |
||
| 71 | * @parem bool $required |
||
| 72 | * @parem array $attributes |
||
| 73 | */ |
||
| 74 | Form::component('hRange', 'form::'.$style.'.horizon.range', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @parem string $name |
||
| 78 | * @parem string $label |
||
| 79 | * @parem bool $required |
||
| 80 | * @parem array $attributes |
||
| 81 | */ |
||
| 82 | Form::component('hSearch', 'form::'.$style.'.horizon.search', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @parem string $name |
||
| 86 | * @parem string $label |
||
| 87 | * @parem bool $required |
||
| 88 | * @parem array $attributes |
||
| 89 | */ |
||
| 90 | Form::component('hTel', 'form::'.$style.'.horizon.tel', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @parem string $name |
||
| 94 | * @parem string $label |
||
| 95 | * @parem bool $required |
||
| 96 | * @parem array $attributes |
||
| 97 | */ |
||
| 98 | Form::component('hNumber', 'form::'.$style.'.horizon.number', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @parem string $name |
||
| 102 | * @parem string $label |
||
| 103 | * @parem bool $required |
||
| 104 | * @parem array $attributes |
||
| 105 | */ |
||
| 106 | Form::component('hDate', 'form::'.$style.'.horizon.date', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @parem string $name |
||
| 110 | * @parem string $label |
||
| 111 | * @parem bool $required |
||
| 112 | * @parem array $attributes |
||
| 113 | */ |
||
| 114 | Form::component('hUrl', 'form::'.$style.'.horizon.url', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @parem string $name |
||
| 118 | * @parem string $label |
||
| 119 | * @parem bool $required |
||
| 120 | * @parem array $attributes |
||
| 121 | */ |
||
| 122 | Form::component('hFile', 'form::'.$style.'.horizon.file', ['name', 'label', 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @parem string $name |
||
| 126 | * @parem string $label |
||
| 127 | * @parem bool $required |
||
| 128 | * @parem array $attributes |
||
| 129 | */ |
||
| 130 | Form::component('hTextarea', 'form::'.$style.'.horizon.textarea', ['name', 'label', 'default' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Create a select box field. |
||
| 134 | * |
||
| 135 | * @param string $name |
||
| 136 | * @param array $list |
||
| 137 | * @param string|bool $selected |
||
| 138 | * @param array $selectAttributes |
||
| 139 | * @param array $optionsAttributes |
||
| 140 | * @param array $optgroupsAttributes |
||
| 141 | */ |
||
| 142 | Form::component('hSelect', 'form::'.$style.'.horizon.select', ['name', 'label', 'data', 'selected' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Create a select box field. |
||
| 146 | * |
||
| 147 | * @param string $name |
||
| 148 | * @param array $list |
||
| 149 | * @param string|bool $selected |
||
| 150 | * @param array $selectAttributes |
||
| 151 | * @param array $optionsAttributes |
||
| 152 | * @param array $optgroupsAttributes |
||
| 153 | */ |
||
| 154 | Form::component('hSelectMulti', 'form::'.$style.'.horizon.selectmulti', ['name', 'label', 'data' => [], 'selected' => [], 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 155 | /** |
||
| 156 | * Create a select range field. |
||
| 157 | * |
||
| 158 | * @param string $name |
||
| 159 | * @param string $begin |
||
| 160 | * @param string $end |
||
| 161 | * @param string $selected |
||
| 162 | * @param array $options |
||
| 163 | * @return HtmlString |
||
| 164 | */ |
||
| 165 | Form::component('hSelectRange', 'form::'.$style.'.horizon.selectrange', ['name', 'label', 'begin', 'end', 'selected' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Create a select month field. |
||
| 169 | * |
||
| 170 | * @param string $name |
||
| 171 | * @param string $selected |
||
| 172 | * @param array $options |
||
| 173 | * @param string $format |
||
| 174 | * @return HtmlString |
||
| 175 | */ |
||
| 176 | Form::component('hSelectMonth', 'form::'.$style.'.horizon.selectmonth', ['name', 'label', 'selected' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Create a checkbox input field. |
||
| 180 | * |
||
| 181 | * @param string $name |
||
| 182 | * @param mixed $value |
||
| 183 | * @param bool $checked |
||
| 184 | * @param array $options |
||
| 185 | * @return HtmlString |
||
| 186 | */ |
||
| 187 | Form::component('hCheckbox', 'form::'.$style.'.horizon.checkbox', ['name', 'label', 'values' => [], 'checked' => [], 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 188 | |||
| 189 | /** |
||
| 190 | * Create a radio button input field. |
||
| 191 | * |
||
| 192 | * @param string $name |
||
| 193 | * @param mixed $value |
||
| 194 | * @param bool $checked |
||
| 195 | * @param array $options |
||
| 196 | * @return HtmlString |
||
| 197 | */ |
||
| 198 | Form::component('hRadio', 'form::'.$style.'.horizon.radio', ['name', 'label', 'values' => [], 'checked' => null, 'required' => false, 'col_size' => 2, 'attributes' => []]); |
||
| 199 | } |
||
| 201 |