Code Duplication    Length = 14-14 lines in 2 locations

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

@@ 193-206 (lines=14) @@
190
	// /sites/%s/posts/%d        -> $blog_id, $post_id
191
	// /sites/%s/posts/%d/delete -> $blog_id, $post_id
192
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
193
	function callback( $path = '', $blog_id = 0, $post_id = 0 ) {
194
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
195
		if ( is_wp_error( $blog_id ) ) {
196
			return $blog_id;
197
		}
198
199
		if ( $this->api->ends_with( $path, '/delete' ) ) {
200
			return $this->delete_post( $path, $blog_id, $post_id );
201
		} elseif ( $this->api->ends_with( $path, '/restore' ) ) {
202
			return $this->restore_post( $path, $blog_id, $post_id );
203
		} else {
204
			return $this->write_post( $path, $blog_id, $post_id );
205
		}
206
	}
207
208
	// /sites/%s/posts/new       -> $blog_id
209
	// /sites/%s/posts/%d        -> $blog_id, $post_id

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

@@ 200-213 (lines=14) @@
197
	// /sites/%s/posts/%d        -> $blog_id, $post_id
198
	// /sites/%s/posts/%d/delete -> $blog_id, $post_id
199
	// /sites/%s/posts/%d/restore -> $blog_id, $post_id
200
	function callback( $path = '', $blog_id = 0, $post_id = 0 ) {
201
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
202
		if ( is_wp_error( $blog_id ) ) {
203
			return $blog_id;
204
		}
205
206
		if ( $this->api->ends_with( $path, '/delete' ) ) {
207
			return $this->delete_post( $path, $blog_id, $post_id );
208
		} elseif ( $this->api->ends_with( $path, '/restore' ) ) {
209
			return $this->restore_post( $path, $blog_id, $post_id );
210
		} else {
211
			return $this->write_post( $path, $blog_id, $post_id );
212
		}
213
	}
214
215
	// /sites/%s/posts/new       -> $blog_id
216
	// /sites/%s/posts/%d        -> $blog_id, $post_id