Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 593-611 (lines=19) @@
590
	 *
591
	 * @return object
592
	 */
593
	function get_attachment( $attachment ) {
594
		$metadata = wp_get_attachment_metadata( $attachment->ID );
595
596
		$result = array(
597
			'ID'		=> (int) $attachment->ID,
598
			'URL'           => (string) wp_get_attachment_url( $attachment->ID ),
599
			'guid'		=> (string) $attachment->guid,
600
			'mime_type'	=> (string) $attachment->post_mime_type,
601
			'width'		=> (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
602
			'height'	=> (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
603
		);
604
605
		if ( isset( $metadata['duration'] ) ) {
606
			$result['duration'] = (int) $metadata['duration'];
607
		}
608
609
		return (object) apply_filters( 'get_attachment', $result );
610
	}
611
612
	/**
613
	 * Get post-specific user capabilities
614
	 * @param  WP_Post $post              post object

sal/class.json-api-post-base.php 1 location

@@ 287-305 (lines=19) @@
284
		return $format;
285
	}
286
287
	private function get_attachment( $attachment ) {
288
		$metadata = wp_get_attachment_metadata( $attachment->ID );
289
290
		$result = array(
291
			'ID'        => (int) $attachment->ID,
292
			'URL'       => (string) wp_get_attachment_url( $attachment->ID ),
293
			'guid'      => (string) $attachment->guid,
294
			'mime_type' => (string) $attachment->post_mime_type,
295
			'width'     => (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
296
			'height'    => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
297
		);
298
299
		if ( isset( $metadata['duration'] ) ) {
300
			$result['duration'] = (int) $metadata['duration'];
301
		}
302
303
		/** This filter is documented in class.jetpack-sync.php */
304
		return (object) apply_filters( 'get_attachment', $result );
305
	}
306
307
	public function get_date() {
308
		return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date );