| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | */ |
| 28 | 28 | private $active_field_size; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * @var bool flagged while calling get_field_layout_class, true if classes contain frm_first class. | |
| 31 | + * @var bool $is_frm_first flagged while calling get_field_layout_class, true if classes contain frm_first class. | |
| 32 | 32 | */ |
| 33 | 33 | private $is_frm_first; |
| 34 | 34 | |
| 35 | 35 | /** |
| @@ -37,19 +37,19 @@ | ||
| 37 | 37 | */ |
| 38 | 38 | private $field; |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * @var FrmFieldGridHelper | |
| 41 | + * @var FrmFieldGridHelper $section_helper | |
| 42 | 42 | */ |
| 43 | 43 | private $section_helper; |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * @var bool | |
| 46 | + * @var bool $nested | |
| 47 | 47 | */ |
| 48 | 48 | private $nested; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @var int | |
| 51 | + * @var int $section_size | |
| 52 | 52 | */ |
| 53 | 53 | private $section_size; |
| 54 | 54 | |
| 55 | 55 | private $section_is_open = false; |
| @@ -62,10 +62,8 @@ | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @param stdClass $field |
| 66 | - * | |
| 67 | - * @return void | |
| 68 | 66 | */ |
| 69 | 67 | public function set_field( $field ) { |
| 70 | 68 | $this->field = $field; |
| 71 | 69 | |
| @@ -80,9 +78,9 @@ | ||
| 80 | 78 | $this->section_is_open = false; |
| 81 | 79 | $this->maybe_close_section_helper(); |
| 82 | 80 | } else { |
| 83 | 81 | $this->field_layout_class = $this->get_field_layout_class(); |
| 84 | - $this->active_field_size = self::get_size_of_class( $this->field_layout_class ); | |
| 82 | + $this->active_field_size = $this->get_size_of_class( $this->field_layout_class ); | |
| 85 | 83 | } |
| 86 | 84 | |
| 87 | 85 | if ( 'divider' === $field->type && empty( $this->nested ) ) { |
| 88 | 86 | $this->section_size = $this->active_field_size; |
| @@ -90,11 +88,8 @@ | ||
| 90 | 88 | $this->section_helper = new self( true ); |
| 91 | 89 | } |
| 92 | 90 | } |
| 93 | 91 | |
| 94 | - /** | |
| 95 | - * @return void | |
| 96 | - */ | |
| 97 | 92 | private function maybe_close_section_helper() { |
| 98 | 93 | if ( empty( $this->section_helper ) ) { |
| 99 | 94 | return; |
| 100 | 95 | } |
| @@ -124,11 +119,8 @@ | ||
| 124 | 119 | |
| 125 | 120 | return ''; |
| 126 | 121 | } |
| 127 | 122 | |
| 128 | - /** | |
| 129 | - * @return void | |
| 130 | - */ | |
| 131 | 123 | public function maybe_begin_field_wrapper() { |
| 132 | 124 | if ( $this->should_first_close_the_active_field_wrapper() ) { |
| 133 | 125 | $this->close_field_wrapper(); |
| 134 | 126 | } |
| @@ -154,11 +146,8 @@ | ||
| 154 | 146 | } |
| 155 | 147 | return ! $this->can_support_current_layout() || $this->is_frm_first; |
| 156 | 148 | } |
| 157 | 149 | |
| 158 | - /** | |
| 159 | - * @return void | |
| 160 | - */ | |
| 161 | 150 | private function begin_field_wrapper() { |
| 162 | 151 | echo '<li class="frm_field_box"><ul class="frm_grid_container frm_sorting">'; |
| 163 | 152 | $this->parent_li = true; |
| 164 | 153 | $this->current_list_size = 0; |
| @@ -195,13 +184,10 @@ | ||
| 195 | 184 | // Anything missing a layout class should be a full width row. |
| 196 | 185 | return 12; |
| 197 | 186 | } |
| 198 | 187 | |
| 199 | - /** | |
| 200 | - * @return void | |
| 201 | - */ | |
| 202 | 188 | public function sync_list_size() { |
| 203 | - if ( empty( $this->field ) ) { | |
| 189 | + if ( ! isset( $this->field ) ) { | |
| 204 | 190 | return; |
| 205 | 191 | } |
| 206 | 192 | |
| 207 | 193 | if ( 'divider' === $this->field->type ) { |
| @@ -216,9 +202,9 @@ | ||
| 216 | 202 | return; |
| 217 | 203 | } |
| 218 | 204 | |
| 219 | 205 | if ( false !== $this->parent_li ) { |
| 220 | - ++$this->current_field_count; | |
| 206 | + $this->current_field_count ++; | |
| 221 | 207 | $this->current_list_size += $this->active_field_size; |
| 222 | 208 | if ( 12 === $this->current_list_size ) { |
| 223 | 209 | $this->close_field_wrapper(); |
| 224 | 210 | } |
| @@ -227,10 +213,8 @@ | ||
| 227 | 213 | |
| 228 | 214 | /** |
| 229 | 215 | * It is possible that there was still space for another field so the wrapper could still be open after looping the fields. |
| 230 | 216 | * If it is, make sure it's closed now. |
| 231 | - * | |
| 232 | - * @return void | |
| 233 | 217 | */ |
| 234 | 218 | public function force_close_field_wrapper() { |
| 235 | 219 | if ( false !== $this->parent_li ) { |
| 236 | 220 | $this->close_field_wrapper(); |
| @@ -236,11 +220,8 @@ | ||
| 236 | 220 | $this->close_field_wrapper(); |
| 237 | 221 | } |
| 238 | 222 | } |
| 239 | 223 | |
| 240 | - /** | |
| 241 | - * @return void | |
| 242 | - */ | |
| 243 | 224 | private function close_field_wrapper() { |
| 244 | 225 | $this->maybe_close_section_helper(); |
| 245 | 226 | echo '</ul></li>'; |
| 246 | 227 | $this->parent_li = false; |
| @@ -247,11 +228,8 @@ | ||
| 247 | 228 | $this->current_list_size = 0; |
| 248 | 229 | $this->current_field_count = 0; |
| 249 | 230 | } |
| 250 | 231 | |
| 251 | - /** | |
| 252 | - * @return bool | |
| 253 | - */ | |
| 254 | 232 | private function can_support_current_layout() { |
| 255 | 233 | if ( 'end_divider' === $this->field->type ) { |
| 256 | 234 | return true; |
| 257 | 235 | } |
| @@ -262,9 +240,9 @@ | ||
| 262 | 240 | * @param string $class |
| 263 | 241 | * @return bool |
| 264 | 242 | */ |
| 265 | 243 | private function can_support_an_additional_layout( $class ) { |
| 266 | - $size = self::get_size_of_class( $class ); | |
| 244 | + $size = $this->get_size_of_class( $class ); | |
| 267 | 245 | return $this->current_list_size + $size <= 12; |
| 268 | 246 | } |
| 269 | 247 | |
| 270 | 248 | /** |