| Conditions | 20 | 
| Paths | 6 | 
| Total Lines | 111 | 
| Lines | 32 | 
| Ratio | 28.83 % | 
| 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 //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName  | 
            ||
| 50 | 	public static function render( $attr, $content ) { | 
            ||
| 51 | Jetpack_Gutenberg::load_assets_as_required( self::FEATURE_NAME );  | 
            ||
| 52 | |||
| 53 | $is_squareish_layout = self::is_squareish_layout( $attr );  | 
            ||
| 54 | |||
| 55 | // Jetpack_Plan does not exist on WordPress.com.  | 
            ||
| 56 | 		if ( class_exists( 'Jetpack_Plan' ) ) { | 
            ||
| 57 | $jetpack_plan = Jetpack_Plan::get();  | 
            ||
| 58 | wp_localize_script( 'jetpack-gallery-settings', 'jetpack_plan', array( 'data' => $jetpack_plan['product_slug'] ) );  | 
            ||
| 59 | }  | 
            ||
| 60 | |||
| 61 | 		if ( preg_match_all( '/<img [^>]+>/', $content, $images ) ) { | 
            ||
| 62 | /**  | 
            ||
| 63 | * This block processes all of the images that are found and builds $find and $replace.  | 
            ||
| 64 | *  | 
            ||
| 65 | * The original img is added to the $find array and the replacement is made and added  | 
            ||
| 66 | * to the $replace array. This is so that the same find and replace operations can be  | 
            ||
| 67 | * made on the entire $content.  | 
            ||
| 68 | */  | 
            ||
| 69 | $find = array();  | 
            ||
| 70 | $replace = array();  | 
            ||
| 71 | |||
| 72 | 			foreach ( $images[0] as $image_html ) { | 
            ||
| 73 | if (  | 
            ||
| 74 | preg_match( '/data-width="([0-9]+)"/', $image_html, $img_height )  | 
            ||
| 75 | && preg_match( '/data-height="([0-9]+)"/', $image_html, $img_width )  | 
            ||
| 76 | && preg_match( '/src="([^"]+)"/', $image_html, $img_src )  | 
            ||
| 77 | 				) { | 
            ||
| 78 | // Drop img src query string so it can be used as a base to add photon params  | 
            ||
| 79 | // for the srcset.  | 
            ||
| 80 | $src_parts = explode( '?', $img_src[1], 2 );  | 
            ||
| 81 | $orig_src = $src_parts[0];  | 
            ||
| 82 | $orig_height = absint( $img_height[1] );  | 
            ||
| 83 | $orig_width = absint( $img_width[1] );  | 
            ||
| 84 | |||
| 85 | // Because URLs are already "photon", the photon function used short-circuits  | 
            ||
| 86 | // before ssl is added. Detect ssl and add is if necessary.  | 
            ||
| 87 | $is_ssl = ! empty( $src_parts[1] ) && false !== strpos( $src_parts[1], 'ssl=1' );  | 
            ||
| 88 | |||
| 89 | 					if ( ! $orig_width || ! $orig_height || ! $orig_src ) { | 
            ||
| 90 | continue;  | 
            ||
| 91 | }  | 
            ||
| 92 | |||
| 93 | $srcset_parts = array();  | 
            ||
| 94 | 					if ( $is_squareish_layout ) { | 
            ||
| 95 | $min_width = min( self::IMG_SRCSET_WIDTH_MIN, $orig_width, $orig_height );  | 
            ||
| 96 | $max_width = min( self::IMG_SRCSET_WIDTH_MAX, $orig_width, $orig_height );  | 
            ||
| 97 | |||
| 98 | View Code Duplication | 						for ( $w = $min_width; $w <= $max_width; $w = min( $max_width, $w + self::IMG_SRCSET_WIDTH_STEP ) ) { | 
            |
| 99 | $srcset_src = add_query_arg(  | 
            ||
| 100 | array(  | 
            ||
| 101 | 'resize' => $w . ',' . $w,  | 
            ||
| 102 | 'strip' => 'info',  | 
            ||
| 103 | ),  | 
            ||
| 104 | $orig_src  | 
            ||
| 105 | );  | 
            ||
| 106 | 							if ( $is_ssl ) { | 
            ||
| 107 | $srcset_src = add_query_arg( 'ssl', '1', $srcset_src );  | 
            ||
| 108 | }  | 
            ||
| 109 | $srcset_parts[] = esc_url( $srcset_src ) . ' ' . $w . 'w';  | 
            ||
| 110 | 							if ( $w >= $max_width ) { | 
            ||
| 111 | break;  | 
            ||
| 112 | }  | 
            ||
| 113 | }  | 
            ||
| 114 | 					} else { | 
            ||
| 115 | $min_width = min( self::IMG_SRCSET_WIDTH_MIN, $orig_width );  | 
            ||
| 116 | $max_width = min( self::IMG_SRCSET_WIDTH_MAX, $orig_width );  | 
            ||
| 117 | |||
| 118 | View Code Duplication | 						for ( $w = $min_width; $w <= $max_width; $w = min( $max_width, $w + self::IMG_SRCSET_WIDTH_STEP ) ) { | 
            |
| 119 | $srcset_src = add_query_arg(  | 
            ||
| 120 | array(  | 
            ||
| 121 | 'strip' => 'info',  | 
            ||
| 122 | 'w' => $w,  | 
            ||
| 123 | ),  | 
            ||
| 124 | $orig_src  | 
            ||
| 125 | );  | 
            ||
| 126 | 							if ( $is_ssl ) { | 
            ||
| 127 | $srcset_src = add_query_arg( 'ssl', '1', $srcset_src );  | 
            ||
| 128 | }  | 
            ||
| 129 | $srcset_parts[] = esc_url( $srcset_src ) . ' ' . $w . 'w';  | 
            ||
| 130 | 							if ( $w >= $max_width ) { | 
            ||
| 131 | break;  | 
            ||
| 132 | }  | 
            ||
| 133 | }  | 
            ||
| 134 | }  | 
            ||
| 135 | |||
| 136 | 					if ( ! empty( $srcset_parts ) ) { | 
            ||
| 137 | $srcset = 'srcset="' . esc_attr( implode( ',', $srcset_parts ) ) . '"';  | 
            ||
| 138 | |||
| 139 | $find[] = $image_html;  | 
            ||
| 140 | $replace[] = str_replace( '<img', '<img ' . $srcset, $image_html );  | 
            ||
| 141 | }  | 
            ||
| 142 | }  | 
            ||
| 143 | }  | 
            ||
| 144 | |||
| 145 | 			if ( ! empty( $find ) ) { | 
            ||
| 146 | $content = str_replace( $find, $replace, $content );  | 
            ||
| 147 | }  | 
            ||
| 148 | }  | 
            ||
| 149 | |||
| 150 | /**  | 
            ||
| 151 | * Filter the output of the Tiled Galleries content.  | 
            ||
| 152 | *  | 
            ||
| 153 | * @module tiled-gallery  | 
            ||
| 154 | *  | 
            ||
| 155 | * @since 6.9.0  | 
            ||
| 156 | *  | 
            ||
| 157 | * @param string $content Tiled Gallery block content.  | 
            ||
| 158 | */  | 
            ||
| 159 | return apply_filters( 'jetpack_tiled_galleries_block_content', $content );  | 
            ||
| 160 | }  | 
            ||
| 161 | |||
| 181 | 
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.