Completed
Push — update/import-sync-detection ( 0bf98c...8808a0 )
by
unknown
25:48 queued 17:49
created

Jetpack_Tiled_Gallery_Block::render()   F

Complexity

Conditions 19
Paths 3

Size

Total Lines 105

Duplication

Lines 32
Ratio 30.48 %

Importance

Changes 0
Metric Value
cc 19
nc 3
nop 2
dl 32
loc 105
rs 3.6133
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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:

1
<?php
2
/**
3
 * Tiled Gallery block. Depends on the Photon module.
4
 *
5
 * @since 6.9.0
6
 *
7
 * @package Jetpack
8
 */
9
10
if (
11
	( defined( 'IS_WPCOM' ) && IS_WPCOM ) ||
12
	class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' )
13
) {
14
	jetpack_register_block(
15
		'jetpack/tiled-gallery',
16
		array(
17
			'render_callback' => 'jetpack_tiled_gallery_load_block_assets',
18
		)
19
	);
20
21
	/**
22
	 * Tiled gallery block registration/dependency declaration.
23
	 *
24
	 * @param array  $attr    Array containing the block attributes.
25
	 * @param string $content String containing the block content.
26
	 *
27
	 * @return string
28
	 */
29
	function jetpack_tiled_gallery_load_block_assets( $attr, $content ) {
30
		Jetpack_Gutenberg::load_assets_as_required(
31
			'tiled-gallery',
32
			array( 'wp-polyfill' )
33
		);
34
35
		/**
36
		 * Filter the output of the Tiled Galleries content.
37
		 *
38
		 * @module tiled-gallery
39
		 *
40
		 * @since 6.9.0
41
		 *
42
		 * @param string $content Tiled Gallery block content.
43
		 */
44
		return apply_filters( 'jetpack_tiled_galleries_block_content', $content );
45
	}
46
}
47