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