| Conditions | 18 | 
| Paths | 1538 | 
| Total Lines | 65 | 
| Code Lines | 39 | 
| Lines | 0 | 
| Ratio | 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  | 
            ||
| 24 | function slideshare_shortcode( $atts ) { | 
            ||
| 25 | global $content_width;  | 
            ||
| 26 | |||
| 27 | $params = shortcode_new_to_old_params( $atts );  | 
            ||
| 28 | parse_str( $params, $arguments );  | 
            ||
| 29 | |||
| 30 | if ( empty( $arguments ) )  | 
            ||
| 31 | return '<!-- SlideShare error: no arguments -->';  | 
            ||
| 32 | |||
| 33 | extract( $arguments );  | 
            ||
| 34 | |||
| 35 | // check that the Slideshare ID contains letters, numbers and query strings  | 
            ||
| 36 | $pattern = '/[^-_a-zA-Z0-9?=&]/';  | 
            ||
| 37 | if ( empty( $id ) || preg_match( $pattern, $id ) )  | 
            ||
| 38 | return '<!-- SlideShare error: id is missing or has illegal characters -->';  | 
            ||
| 39 | |||
| 40 | // check the width/height  | 
            ||
| 41 | if ( empty( $w ) && ! empty( $content_width ) )  | 
            ||
| 42 | $w = intval( $content_width );  | 
            ||
| 43 | elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 )  | 
            ||
| 44 | $w = 425;  | 
            ||
| 45 | else  | 
            ||
| 46 | $w = intval( $w );  | 
            ||
| 47 | |||
| 48 | $h = ceil( $w * 348 / 425 );  | 
            ||
| 49 | |||
| 50 | 	if ( isset( $pro ) ) { | 
            ||
| 51 | $source = "https://www.slideshare.net/slidesharepro/$id";  | 
            ||
| 52 | 	} else { | 
            ||
| 53 | $source = "https://www.slideshare.net/slideshow/embed_code/$id";  | 
            ||
| 54 | }  | 
            ||
| 55 | |||
| 56 | if ( isset( $rel ) )  | 
            ||
| 57 | $source = add_query_arg( 'rel', intval( $rel ), $source );  | 
            ||
| 58 | |||
| 59 | if ( isset( $startSlide ) )  | 
            ||
| 60 | $source = add_query_arg( 'startSlide', intval( $startSlide ), $source );  | 
            ||
| 61 | |||
| 62 | $player = sprintf( "<iframe src='%s' width='%d' height='%d'", esc_url( $source ), $w, $h );  | 
            ||
| 63 | |||
| 64 | // check the frameborder  | 
            ||
| 65 | if ( isset( $fb ) )  | 
            ||
| 66 | $player .= " frameborder='" . intval( $fb ) . "'";  | 
            ||
| 67 | |||
| 68 | // check the margin width; if not empty, cast as int  | 
            ||
| 69 | if ( isset( $mw ) )  | 
            ||
| 70 | $player .= " marginwidth='" . intval( $mw ) . "'";  | 
            ||
| 71 | |||
| 72 | // check the margin height, if not empty, cast as int  | 
            ||
| 73 | if ( isset( $mh ) )  | 
            ||
| 74 | $player .= " marginheight='" . intval( $mh ) . "'";  | 
            ||
| 75 | |||
| 76 | if ( ! empty( $style ) )  | 
            ||
| 77 | $player .= " style='" . $style . "'";  | 
            ||
| 78 | |||
| 79 | // check the scrollbar; cast as a lowercase string for comparison  | 
            ||
| 80 | $sc = isset( $sc ) ? strtolower( $sc ) : '';  | 
            ||
| 81 | |||
| 82 | if ( in_array( $sc, array( 'yes', 'no' ) ) )  | 
            ||
| 83 | $player .= " scrolling='" . $sc . "'";  | 
            ||
| 84 | |||
| 85 | $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>';  | 
            ||
| 86 | |||
| 87 | return $player;  | 
            ||
| 88 | }  |