Code Duplication    Length = 11-12 lines in 2 locations

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

@@ 265-275 (lines=11) @@
262
	 *
263
	 * @return string
264
	 */
265
	private function get_time_string_from_guid( $media_id ) {
266
		$time = date( "Y/m", strtotime( current_time( 'mysql' ) ) );
267
		if ( $media = get_post( $media_id ) ) {
268
			$pattern = '/\/(\d{4}\/\d{2})\//';
269
			preg_match( $pattern, $media->guid, $matches );
270
			if ( count( $matches ) > 1 ) {
271
				$time = $matches[1];
272
			}
273
		}
274
		return $time;
275
	}
276
277
	/**
278
	 * Get the image from a remote url and then save it locally.

_inc/lib/class.media.php 1 location

@@ 76-87 (lines=12) @@
73
	 * @param  number $media_id
74
	 * @return string
75
	 */
76
	private static function get_time_string_from_guid( $media_id ) {
77
		$time = date( "Y/m", strtotime( current_time( 'mysql' ) ) );
78
79
		if ( $media = get_post( $media_id ) ) {
80
			$pattern = '/\/(\d{4}\/\d{2})\//';
81
			preg_match( $pattern, $media->guid, $matches );
82
			if ( count( $matches ) > 1 ) {
83
				$time = $matches[1];
84
			}
85
		}
86
		return $time;
87
	}
88
89
	/**
90
	 * Return an array of allowed mime_type items used to upload a media file.