Code Duplication    Length = 15-15 lines in 2 locations

forms/AssetField.php 1 location

@@ 741-755 (lines=15) @@
738
	 * @param string $default Default value to return if no value could be calculated
739
	 * @return string Foreign class name.
740
	 */
741
	public function getRelationAutosetClass($default = 'File') {
742
743
		// Don't autodetermine relation if no relationship between parent record
744
		if(!$this->relationAutoSetting) return $default;
745
746
		// Check record and name
747
		$name = $this->getName();
748
		$record = $this->getRecord();
749
		if(empty($name) || empty($record)) {
750
			return $default;
751
		} else {
752
			$class = $record->getRelationClass($name);
753
			return empty($class) ? $default : $class;
754
		}
755
	}
756
757
	/**
758
	 * @return AssetStore

forms/UploadField.php 1 location

@@ 1320-1334 (lines=15) @@
1317
	 * @param string $default Default value to return if no value could be calculated
1318
	 * @return string Foreign class name.
1319
	 */
1320
	public function getRelationAutosetClass($default = 'File') {
1321
1322
		// Don't autodetermine relation if no relationship between parent record
1323
		if(!$this->relationAutoSetting) return $default;
1324
1325
		// Check record and name
1326
		$name = $this->getName();
1327
		$record = $this->getRecord();
1328
		if(empty($name) || empty($record)) {
1329
			return $default;
1330
		} else {
1331
			$class = $record->getRelationClass($name);
1332
			return empty($class) ? $default : $class;
1333
		}
1334
	}
1335
1336
}
1337