Code Duplication    Length = 12-12 lines in 2 locations

includes/media/GIF.php 1 location

@@ 199-210 (lines=12) @@
196
	 * @param File $file
197
	 * @return float The duration of the file.
198
	 */
199
	public function getLength( $file ) {
200
		$serMeta = $file->getMetadata();
201
		MediaWiki\suppressWarnings();
202
		$metadata = unserialize( $serMeta );
203
		MediaWiki\restoreWarnings();
204
205
		if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) {
206
			return 0.0;
207
		} else {
208
			return (float)$metadata['duration'];
209
		}
210
	}
211
}
212

includes/media/PNG.php 1 location

@@ 186-197 (lines=12) @@
183
	 * @param File $file
184
	 * @return float The duration of the file.
185
	 */
186
	public function getLength( $file ) {
187
		$serMeta = $file->getMetadata();
188
		MediaWiki\suppressWarnings();
189
		$metadata = unserialize( $serMeta );
190
		MediaWiki\restoreWarnings();
191
192
		if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) {
193
			return 0.0;
194
		} else {
195
			return (float)$metadata['duration'];
196
		}
197
	}
198
199
	// PNGs should be easy to support, but it will need some sharpening applied
200
	// and another user test to check if the perceived quality change is noticeable