| Conditions | 2 |
| Paths | 2 |
| Total Lines | 156 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 1 | Features | 2 |
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 |
||
| 55 | public function boot() |
||
| 56 | { |
||
| 57 | $style = Config::get('form.style'); |
||
| 58 | |||
| 59 | if ($style == null) { |
||
| 60 | $style = 'bootstrap4'; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @parem string $name |
||
| 65 | * @parem string $label |
||
| 66 | * @parem mixed $default |
||
| 67 | * @parem bool $required |
||
| 68 | * @parem array $attributes |
||
| 69 | * |
||
| 70 | * @return HtmlString |
||
| 71 | */ |
||
| 72 | Form::component('gText', 'form::'.$style.'.group.text', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 73 | /** |
||
| 74 | * @parem string $name |
||
| 75 | * @parem string $label |
||
| 76 | * @parem mixed $default |
||
| 77 | * @parem bool $required |
||
| 78 | * @parem array $attributes |
||
| 79 | * |
||
| 80 | * @return HtmlString |
||
| 81 | */ |
||
| 82 | Form::component('gEmail', 'form::'.$style.'.group.email', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @parem string $name |
||
| 86 | * @parem string $label |
||
| 87 | * @parem bool $required |
||
| 88 | * @parem array $attributes |
||
| 89 | * |
||
| 90 | * @return HtmlString |
||
| 91 | */ |
||
| 92 | Form::component('gPassword', 'form::'.$style.'.group.password', ['name', 'label', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @parem string $name |
||
| 96 | * @parem string $label |
||
| 97 | * @parem bool $required |
||
| 98 | * @parem array $attributes |
||
| 99 | * |
||
| 100 | * @return HtmlString |
||
| 101 | */ |
||
| 102 | Form::component('gSearch', 'form::'.$style.'.group.search', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @parem string $name |
||
| 106 | * @parem string $label |
||
| 107 | * @parem bool $required |
||
| 108 | * @parem array $attributes |
||
| 109 | * |
||
| 110 | * @return HtmlString |
||
| 111 | */ |
||
| 112 | Form::component('gTel', 'form::'.$style.'.group.tel', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @parem string $name |
||
| 116 | * @parem string $label |
||
| 117 | * @parem bool $required |
||
| 118 | * @parem array $attributes |
||
| 119 | * |
||
| 120 | * @return HtmlString |
||
| 121 | */ |
||
| 122 | Form::component('gNumber', 'form::'.$style.'.group.number', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @parem string $name |
||
| 126 | * @parem string $label |
||
| 127 | * @parem bool $required |
||
| 128 | * @parem array $attributes |
||
| 129 | * |
||
| 130 | * @return HtmlString |
||
| 131 | */ |
||
| 132 | Form::component('gDate', 'form::'.$style.'.group.date', ['name', 'label', 'default' => date('Y-m-d'), 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @parem string $name |
||
| 136 | * @parem string $label |
||
| 137 | * @parem bool $required |
||
| 138 | * @parem array $attributes |
||
| 139 | * |
||
| 140 | * @return HtmlString |
||
| 141 | */ |
||
| 142 | Form::component('gUrl', 'form::'.$style.'.group.url', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @parem string $name |
||
| 146 | * @parem string $label |
||
| 147 | * @parem bool $required |
||
| 148 | * @parem array $attributes |
||
| 149 | * |
||
| 150 | * @return HtmlString |
||
| 151 | */ |
||
| 152 | Form::component('gTextarea', 'form::'.$style.'.group.textarea', ['name', 'label', 'default' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Create a select box field. |
||
| 156 | * |
||
| 157 | * @param string $name |
||
| 158 | * @param array $list |
||
| 159 | * @param string|bool $selected |
||
| 160 | * @param array $selectAttributes |
||
| 161 | * @param array $optionsAttributes |
||
| 162 | * @param array $optgroupsAttributes |
||
| 163 | */ |
||
| 164 | Form::component('gSelect', 'form::'.$style.'.group.select', ['name', 'label', 'data', 'selected', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Create a select box field. |
||
| 168 | * |
||
| 169 | * @param string $name |
||
| 170 | * @param array $list |
||
| 171 | * @param string|bool $selected |
||
| 172 | * @param array $selectAttributes |
||
| 173 | * @param array $optionsAttributes |
||
| 174 | * @param array $optgroupsAttributes |
||
| 175 | */ |
||
| 176 | Form::component('gSelectMulti', 'form::'.$style.'.group.selectmulti', ['name', 'label', 'data' => [], 'selected' => [], 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Create a select range field. |
||
| 180 | * |
||
| 181 | * @param string $name |
||
| 182 | * @param string $begin |
||
| 183 | * @param string $end |
||
| 184 | * @param string $selected |
||
| 185 | * @param array $options |
||
| 186 | * @return HtmlString |
||
| 187 | */ |
||
| 188 | Form::component('gSelectRange', 'form::'.$style.'.group.selectrange', ['name', 'label', 'begin', 'end', 'selected', 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Create a select day field. |
||
| 192 | * |
||
| 193 | * @param string $name |
||
| 194 | * @param string $selected |
||
| 195 | * @param array $options |
||
| 196 | * @param string $format |
||
| 197 | * @return HtmlString |
||
| 198 | */ |
||
| 199 | Form::component('gSelectDay', 'form::'.$style.'.group.selectday', ['name', 'label', 'selected' => null, 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Create a select month field. |
||
| 203 | * |
||
| 204 | * @param string $name |
||
| 205 | * @param string $selected |
||
| 206 | * @param array $options |
||
| 207 | * @param string $format |
||
| 208 | * @return HtmlString |
||
| 209 | */ |
||
| 210 | Form::component('gSelectMonth', 'form::'.$style.'.group.selectmonth', ['name', 'label', 'selected' => date('m'), 'required' => false, 'icon' => null, 'position' => 'before', 'attributes' => []]); |
||
| 211 | } |
||
| 213 |