Code Duplication    Length = 15-15 lines in 2 locations

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.

_inc/lib/class.media.php 1 location

@@ 192-206 (lines=15) @@
189
	 * @param  object $media_item - media post object
190
	 * @return object a revision item
191
	 */
192
	public static function get_snapshot( $media_item ) {
193
		$current_file = get_attached_file( $media_item->ID );
194
		$file_paths = pathinfo( $current_file );
195
196
		$snapshot = array(
197
			'date'             => (string) WPCOM_JSON_API_Date::format_date( $media_item->post_modified_gmt, $media_item->post_modified ),
198
			'URL'              => (string) wp_get_attachment_url( $media_item->ID ),
199
			'file'             => (string) $file_paths['basename'],
200
			'extension'        => (string) $file_paths['extension'],
201
			'mime_type'        => (string) $media_item->post_mime_type,
202
			'size'             => (int) filesize( $current_file ),
203
		);
204
205
		return (object) $snapshot;
206
	}
207
208
	/**
209
	 * Add a new item into revision_history array.