Conditions | 12 |
Paths | 192 |
Total Lines | 49 |
Code Lines | 21 |
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 |
||
151 | private function set_properties( $view ) { |
||
152 | |||
153 | // Set styles. |
||
154 | if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) { |
||
155 | $this->theme = 'dark'; |
||
156 | } |
||
157 | if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) { |
||
158 | $this->today_color = esc_attr( $today_color ); |
||
159 | } |
||
160 | if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) { |
||
161 | $this->days_events_color = esc_attr( $day_events_color ); |
||
162 | } |
||
163 | |||
164 | // Hide too many events. |
||
165 | if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) { |
||
166 | $this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) ); |
||
167 | } |
||
168 | |||
169 | // Expand multiple day events. |
||
170 | if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) || ( 'list' == $view && 'current_day_only' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) ) { |
||
171 | $this->events = $this->expand_multiple_days_events(); |
||
172 | } |
||
173 | |||
174 | if ( 'grid' == $view ) { |
||
175 | |||
176 | // Use hover to open event bubbles. |
||
177 | if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) { |
||
178 | $this->event_bubble_trigger = 'hover'; |
||
179 | } |
||
180 | |||
181 | // Trim long event titles. |
||
182 | if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) { |
||
183 | $this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 ); |
||
184 | } |
||
185 | |||
186 | } else { |
||
187 | |||
188 | // List range. |
||
189 | $this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) ); |
||
190 | $this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 ); |
||
191 | |||
192 | // Make the list look more compact. |
||
193 | if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) { |
||
194 | $this->compact_list = true; |
||
195 | } |
||
196 | |||
197 | } |
||
198 | |||
199 | } |
||
200 | |||
275 |