Code Duplication    Length = 14-14 lines in 2 locations

json-endpoints/class.wpcom-json-api-update-post-endpoint.php 1 location

@@ 14-27 (lines=14) @@
11
	// /sites/%s/posts/%d        -> $blog_id, $post_id
12
	// /sites/%s/posts/%d/delete -> $blog_id, $post_id
13
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
14
	function callback( $path = '', $blog_id = 0, $post_id = 0 ) {
15
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
16
		if ( is_wp_error( $blog_id ) ) {
17
			return $blog_id;
18
		}
19
20
		if ( $this->api->ends_with( $path, '/delete' ) ) {
21
			return $this->delete_post( $path, $blog_id, $post_id );
22
		} elseif ( $this->api->ends_with( $path, '/restore' ) ) {
23
			return $this->restore_post( $path, $blog_id, $post_id );
24
		} else {
25
			return $this->write_post( $path, $blog_id, $post_id );
26
		}
27
	}
28
29
	// /sites/%s/posts/new       -> $blog_id
30
	// /sites/%s/posts/%d        -> $blog_id, $post_id

json-endpoints/class.wpcom-json-api-update-post-v1-1-endpoint.php 1 location

@@ 14-27 (lines=14) @@
11
	// /sites/%s/posts/%d        -> $blog_id, $post_id
12
	// /sites/%s/posts/%d/delete -> $blog_id, $post_id
13
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
14
	function callback( $path = '', $blog_id = 0, $post_id = 0 ) {
15
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
16
		if ( is_wp_error( $blog_id ) ) {
17
			return $blog_id;
18
		}
19
20
		if ( $this->api->ends_with( $path, '/delete' ) ) {
21
			return $this->delete_post( $path, $blog_id, $post_id );
22
		} elseif ( $this->api->ends_with( $path, '/restore' ) ) {
23
			return $this->restore_post( $path, $blog_id, $post_id );
24
		} else {
25
			return $this->write_post( $path, $blog_id, $post_id );
26
		}
27
	}
28
29
	// /sites/%s/posts/new       -> $blog_id
30
	// /sites/%s/posts/%d        -> $blog_id, $post_id