| Conditions | 2 |
| Paths | 2 |
| Total Lines | 74 |
| Code Lines | 52 |
| 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 |
||
| 109 | public function migrate_gallery( $gallery_id ) { |
||
| 110 | $gallery = FooGallery::get_by_id( $gallery_id ); |
||
| 111 | |||
| 112 | //get the old settings, so we can migrate to the new |
||
| 113 | $settings = $gallery->settings; |
||
| 114 | |||
| 115 | if ( 'videoslider' === $gallery->gallery_template ) { |
||
| 116 | |||
| 117 | //update the gallery template |
||
| 118 | update_post_meta( $gallery_id, FOOGALLERY_META_TEMPLATE, 'slider' ); |
||
| 119 | |||
| 120 | //update the layout setting |
||
| 121 | $this->migrate_setting( $settings, 'videoslider_layout', array( |
||
| 122 | 'rvs-vertical' => '', |
||
| 123 | 'rvs-horizontal' => 'fgs-horizontal' |
||
| 124 | ), 'slider_layout' ); |
||
| 125 | |||
| 126 | //update the viewport setting |
||
| 127 | $this->migrate_setting( $settings, 'videoslider_viewport', array( |
||
| 128 | '' => '', |
||
| 129 | 'rvs-use-viewport' => 'yes' |
||
| 130 | ), 'slider_viewport' ); |
||
| 131 | |||
| 132 | //update the theme setting |
||
| 133 | $this->migrate_setting( $settings, 'videoslider_theme', array( |
||
| 134 | '' => 'fg-dark', |
||
| 135 | 'rvs-light' => 'fg-light', |
||
| 136 | 'rvs-custom' => 'fg-custom' |
||
| 137 | ), 'slider_theme' ); |
||
| 138 | |||
| 139 | //update the highlight setting |
||
| 140 | $this->migrate_setting( $settings, 'videoslider_highlight', array( |
||
| 141 | '' => 'fgs-purple', |
||
| 142 | 'rvs-blue-highlight' => 'fgs-blue', |
||
| 143 | 'rvs-green-highlight' => 'fgs-green', |
||
| 144 | 'rvs-orange-highlight' => 'fgs-orange', |
||
| 145 | 'rvs-red-highlight' => 'fgs-red', |
||
| 146 | 'rvs-custom-highlight' => 'fgs-custom' |
||
| 147 | ), 'slider_highlight' ); |
||
| 148 | } |
||
| 149 | |||
| 150 | //we need to migrate the foovideo settings that are saved on all galleries |
||
| 151 | $this->migrate_setting( $settings, $gallery->gallery_template . '_foovideo_video_overlay', array( |
||
| 152 | 'video-icon-default' => 'fg-video-default', |
||
| 153 | 'video-icon-1' => 'fg-video-1', |
||
| 154 | 'video-icon-2' => 'fg-video-2', |
||
| 155 | 'video-icon-3' => 'fg-video-3', |
||
| 156 | 'video-icon-4' => 'fg-video-4' |
||
| 157 | ), $gallery->gallery_template . '_video_hover_icon' ); |
||
| 158 | |||
| 159 | $this->migrate_setting( $settings, $gallery->gallery_template . '_foovideo_sticky_icon', array( |
||
| 160 | 'video-icon-sticky' => 'fg-video-sticky', |
||
| 161 | '' => '' |
||
| 162 | ), $gallery->gallery_template . '_video_sticky_icon' ); |
||
| 163 | |||
| 164 | $this->migrate_setting( $settings, $gallery->gallery_template . '_foovideo_video_size', array( |
||
| 165 | '640x360' => '640x360', |
||
| 166 | '854x480' => '854x480', |
||
| 167 | '960x540' => '960x540', |
||
| 168 | '1024x576' => '1024x576', |
||
| 169 | '1280x720' => '1280x720', |
||
| 170 | '1366x768' => '1366x768', |
||
| 171 | '1600x900' => '1600x900', |
||
| 172 | '1920x1080' => '1920x1080', |
||
| 173 | ), $gallery->gallery_template . '_video_size' ); |
||
| 174 | |||
| 175 | $this->migrate_setting( $settings, $gallery->gallery_template . '_foovideo_autoplay', array( |
||
| 176 | 'yes' => 'yes', |
||
| 177 | 'no' => 'no' |
||
| 178 | ), $gallery->gallery_template . '_video_autoplay' ); |
||
| 179 | |||
| 180 | //update the gallery settings |
||
| 181 | update_post_meta( $gallery_id, FOOGALLERY_META_SETTINGS, $settings ); |
||
| 182 | } |
||
| 183 | |||
| 224 | } |
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.