Conditions | 13 |
Paths | 22 |
Total Lines | 59 |
Code Lines | 44 |
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 |
||
51 | public function foogallery_build_class_attribute( $classes ) { |
||
52 | global $current_foogallery_template; |
||
53 | |||
54 | //first determine if the gallery has any videos |
||
55 | |||
56 | //get the selected video icon |
||
57 | $video_hover_icon = foogallery_gallery_template_setting( 'video_hover_icon', 'fg-video-default' ); |
||
58 | |||
59 | //backwards compatible for the videoslider |
||
60 | if ( 'videoslider' === $current_foogallery_template ) { |
||
61 | switch ( $video_hover_icon ) { |
||
62 | case 'video-icon-default': |
||
63 | $video_hover_icon = 'rvs-flat-circle-play'; |
||
64 | break; |
||
65 | case 'video-icon-1': |
||
66 | $video_hover_icon = 'rvs-plain-arrow-play'; |
||
67 | break; |
||
68 | case 'video-icon-2': |
||
69 | $video_hover_icon = 'rvs-youtube-play'; |
||
70 | break; |
||
71 | case 'video-icon-3': |
||
72 | $video_hover_icon = 'rvs-bordered-circle-play'; |
||
73 | break; |
||
74 | default: |
||
75 | $video_hover_icon = ''; |
||
76 | } |
||
77 | } else { |
||
78 | switch ( $video_hover_icon ) { |
||
79 | case 'video-icon-default': |
||
80 | $video_hover_icon = 'fg-video-default'; |
||
81 | break; |
||
82 | case 'video-icon-1': |
||
83 | $video_hover_icon = 'fg-video-1'; |
||
84 | break; |
||
85 | case 'video-icon-2': |
||
86 | $video_hover_icon = 'fg-video-2'; |
||
87 | break; |
||
88 | case 'video-icon-3': |
||
89 | $video_hover_icon = 'fg-video-3'; |
||
90 | break; |
||
91 | case 'video-icon-4': |
||
92 | $video_hover_icon = 'fg-video-4'; |
||
93 | break; |
||
94 | default: |
||
95 | $video_hover_icon = ''; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | //include the video icon class |
||
100 | $classes[] = $video_hover_icon; |
||
101 | //get the video icon sticky state |
||
102 | $video_icon_sticky = foogallery_gallery_template_setting( 'foovideo_sticky_icon', '' ); |
||
103 | if ( 'videoslider' === $current_foogallery_template && '' === $video_icon_sticky ) { |
||
104 | $video_icon_sticky = 'rvs-show-play-on-hover'; |
||
105 | } |
||
106 | //include the video sticky class |
||
107 | $classes[] = $video_icon_sticky; |
||
108 | return $classes; |
||
109 | } |
||
110 | |||
166 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.