Code Duplication    Length = 5-6 lines in 3 locations

lib/private/preview.php 2 locations

@@ 587-592 (lines=6) @@
584
		$askedWidth = min($askedWidth, $originalWidth * $scaleFactor);
585
		$askedHeight = min($askedHeight, $originalHeight * $scaleFactor);
586
587
		if ($askedWidth / $originalRatio < $askedHeight) {
588
			// width restricted
589
			$askedHeight = round($askedWidth / $originalRatio);
590
		} else {
591
			$askedWidth = round($askedHeight * $originalRatio);
592
		}
593
594
		return [(int)$askedWidth, (int)$askedHeight];
595
	}
@@ 613-618 (lines=6) @@
610
		$askedWidth = min($askedWidth, $previewWidth * $scaleFactor);
611
		$askedHeight = min($askedHeight, $previewHeight * $scaleFactor);
612
613
		if ($askedWidth / $originalRatio > $askedHeight) {
614
			// height restricted
615
			$askedHeight = round($askedWidth / $originalRatio);
616
		} else {
617
			$askedWidth = round($askedHeight * $originalRatio);
618
		}
619
620
		return [(int)$askedWidth, (int)$askedHeight];
621
	}

tests/lib/preview.php 1 location

@@ 856-860 (lines=5) @@
853
	 */
854
	private function applyAspectRatio($askedWidth, $askedHeight) {
855
		$originalRatio = $this->maxPreviewRatio;
856
		if ($askedWidth / $originalRatio < $askedHeight) {
857
			$askedHeight = round($askedWidth / $originalRatio);
858
		} else {
859
			$askedWidth = round($askedHeight * $originalRatio);
860
		}
861
862
		return [(int)$askedWidth, (int)$askedHeight];
863
	}