| Conditions | 11 |
| Paths | 6 |
| Total Lines | 43 |
| 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 |
||
| 46 | |||
| 47 | $post_id = absint( $attributes['id'] ); |
||
| 48 | $videopress_id = video_get_info_by_blogpostid( $blog_id, $post_id )->guid; |
||
| 49 | $videopress_data = videopress_get_video_details( $videopress_id ); |
||
| 50 | |||
| 51 | if ( empty( $videopress_data->file_url_base->https ) || empty( $videopress_data->files->hd->mp4 ) ) { |
||
| 52 | return $content; |
||
| 53 | } |
||
| 54 | |||
| 55 | $videopress_url = $videopress_data->file_url_base->https . $videopress_data->files->hd->mp4; |
||
| 56 | |||
| 57 | $pattern = '/(\s)src=([\'"])(?:(?!\2).)+?\2/'; |
||
| 58 | |||
| 59 | return preg_replace( |
||
| 60 | $pattern, |
||
| 61 | sprintf( |
||
| 62 | '\1src="%1$s"', |
||
| 63 | esc_url_raw( $videopress_url ) |
||
| 64 | ), |
||
| 65 | $content, |
||
| 66 | 1 |
||
| 67 | ); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | VideoPress_Gutenberg::init(); |
||
| 72 |