Code Duplication    Length = 15-15 lines in 2 locations

_inc/lib/class.media.php 1 location

@@ 234-248 (lines=15) @@
231
	 * @param  object $media_item - media post object
232
	 * @return object a revision item 
233
	 */
234
	public static function get_snapshot( $media_item ) {
235
		$current_file = get_attached_file( $media_item->ID );
236
		$file_paths = pathinfo( $current_file );
237
238
		$snapshot = array(
239
			'date'             => (string) WPCOM_JSON_API_Date::format_date( $media_item->post_modified_gmt, $media_item->post_modified ),
240
			'URL'              => (string) wp_get_attachment_url( $media_item->ID ),
241
			'file'             => (string) $file_paths['basename'],
242
			'extension'        => (string) $file_paths['extension'],
243
			'mime_type'        => (string) $media_item->post_mime_type,
244
			'size'             => (int) filesize( $current_file ) 
245
		);
246
247
		return (object) $snapshot;
248
	}
249
250
	/**
251
	 * Add a new item into revision_history array.

json-endpoints/class.wpcom-json-api-edit-media-v1-2-endpoint.php 1 location

@@ 171-185 (lines=15) @@
168
	 * @param  {Object} $media_item - media post object
169
	 * @return {Object} the snapshot object
170
	 */
171
	private function get_snapshot( $media_item ) {
172
		$current_file = get_attached_file( $media_item->ID );
173
		$file_paths = pathinfo( $current_file );
174
175
		$snapshot = array(
176
			'date'             => (string) $this->format_date( $media_item->post_modified_gmt, $media_item->post_modified ),
177
			'URL'              => (string) wp_get_attachment_url( $media_item->ID ),
178
			'file'             => (string) $file_paths['basename'],
179
			'extension'        => (string) $file_paths['extension'],
180
			'mime_type'        => (string) $media_item->post_mime_type,
181
			'size'             => (int) filesize( $current_file )
182
		);
183
184
		return (object) $snapshot;
185
	}
186
187
	/**
188
	 * Try to remove the temporal file from the given file array.