Code Duplication    Length = 6-12 lines in 2 locations

packages/sync/src/modules/Comments.php 2 locations

@@ 39-44 (lines=6) @@
36
		// even though it's messy, we implement these hooks because
37
		// the edit_comment hook doesn't include the data
38
		// so this saves us a DB read for every comment event
39
		foreach ( array( '', 'trackback', 'pingback' ) as $comment_type ) {
40
			foreach ( array( 'unapproved', 'approved' ) as $comment_status ) {
41
				$comment_action_name = "comment_{$comment_status}_{$comment_type}";
42
				add_action( $comment_action_name, $callable, 10, 2 );
43
			}
44
		}
45
46
		// listen for meta changes
47
		$this->init_listeners_for_meta_type( 'comment', $callable );
@@ 87-98 (lines=12) @@
84
	public function init_before_send() {
85
		add_filter( 'jetpack_sync_before_send_wp_insert_comment', array( $this, 'expand_wp_insert_comment' ) );
86
87
		foreach ( array( '', 'trackback', 'pingback' ) as $comment_type ) {
88
			foreach ( array( 'unapproved', 'approved' ) as $comment_status ) {
89
				$comment_action_name = "comment_{$comment_status}_{$comment_type}";
90
				add_filter(
91
					'jetpack_sync_before_send_' . $comment_action_name,
92
					array(
93
						$this,
94
						'expand_wp_insert_comment',
95
					)
96
				);
97
			}
98
		}
99
100
		// full sync
101
		add_filter( 'jetpack_sync_before_send_jetpack_full_sync_comments', array( $this, 'expand_comment_ids' ) );