Code Duplication    Length = 19-19 lines in 2 locations

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

@@ 619-637 (lines=19) @@
616
	 *
617
	 * @return (object)
618
	 */
619
	function get_attachment( $attachment ) {
620
		$metadata = wp_get_attachment_metadata( $attachment->ID );
621
622
		$result = array(
623
			'ID'		=> (int) $attachment->ID,
624
			'URL'           => (string) wp_get_attachment_url( $attachment->ID ),
625
			'guid'		=> (string) $attachment->guid,
626
			'mime_type'	=> (string) $attachment->post_mime_type,
627
			'width'		=> (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
628
			'height'	=> (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
629
		);
630
631
		if ( isset( $metadata['duration'] ) ) {
632
			$result['duration'] = (int) $metadata['duration'];
633
		}
634
635
		/** This filter is documented in class.jetpack-sync.php */
636
		return (object) apply_filters( 'get_attachment', $result );
637
	}
638
639
	/**
640
	 * Get post-specific user capabilities

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

@@ 634-652 (lines=19) @@
631
	 *
632
	 * @return (object)
633
	 */
634
	function get_attachment( $attachment ) {
635
		$metadata = wp_get_attachment_metadata( $attachment->ID );
636
637
		$result = array(
638
			'ID'		=> (int) $attachment->ID,
639
			'URL'           => (string) wp_get_attachment_url( $attachment->ID ),
640
			'guid'		=> (string) $attachment->guid,
641
			'mime_type'	=> (string) $attachment->post_mime_type,
642
			'width'		=> (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
643
			'height'	=> (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
644
		);
645
646
		if ( isset( $metadata['duration'] ) ) {
647
			$result['duration'] = (int) $metadata['duration'];
648
		}
649
650
		/** This filter is documented in class.jetpack-sync.php */
651
		return (object) apply_filters( 'get_attachment', $result );
652
	}
653
654
	/**
655
	 * Get post-specific user capabilities