Code Duplication    Length = 17-17 lines in 2 locations

lib/connector/importldifconnector.php 1 location

@@ 201-217 (lines=17) @@
198
	 *         1 - 0.5*(number of untranslated elements/total number of elements)
199
	 * The more the first element has untranslated elements, the more the result is close to 0.5
200
	 */
201
	public function getFormatMatch($file) {
202
		// Examining the first element only
203
		$parts = $this->getSourceElementsFromFile($file, 1);
204
205
		if (!$parts || count($parts[0]) == 0) {
206
			// Doesn't look like a ldif file
207
			return 0;
208
		} else {
209
			$element = $this->convertElementToVCard($parts[0]);
210
			if ($element) {
211
				$unknownElements = $element->select("X-Unknown-Element");
212
				return (1 - (0.5 * count($unknownElements)/count($parts[0])));
213
			} else {
214
				return 0;
215
			}
216
		}
217
	}	
218
}
219
220
?>

lib/connector/importvcardconnector.php 1 location

@@ 199-215 (lines=17) @@
196
	 *         1-0.5^(number of translated elements+1)
197
	 * The more the first element has parameters to translate, the more the result is close to 1
198
	 */
199
	public function getFormatMatch($file) {
200
		// Examining the first element only
201
		$parts = $this->getSourceElementsFromFile($file, 1);
202
		
203
		if (!$parts || ($parts && count($parts[0]) == 0)) {
204
			// Doesn't look like a vcf file
205
			return 0;
206
		} else {
207
			$element = $this->convertElementToVCard($parts[0]);
208
			if ($element) {
209
				$unknownElements = $element->select("X-Unknown-Element");
210
				return (1 - (0.5 * count($unknownElements)/count($parts[0])));
211
			} else {
212
				return 0;
213
			}
214
		}
215
	}
216
	
217
}
218