Code Duplication    Length = 11-12 lines in 2 locations

forms/CompositeField.php 1 location

@@ 382-393 (lines=12) @@
379
	 * @return int Position in children collection (first position starts with 0). Returns FALSE if the field can't
380
	 *             be found.
381
	 */
382
	public function fieldPosition($field) {
383
		if(is_string($field)) {
384
			$field = $this->fieldByName($field);
385
		}
386
		if(!$field) {
387
			return false;
388
		}
389
390
		$i = 0;
391
		foreach($this->children as $child) {
392
			/** @var FormField $child */
393
			if($child->getName() == $field->getName()) {
394
				return $i;
395
			}
396
			$i++;

forms/FieldList.php 1 location

@@ 613-623 (lines=11) @@
610
	 * @return int Position in children collection (first position starts with 0). Returns FALSE if the field can't
611
	 *             be found.
612
	 */
613
	public function fieldPosition($field) {
614
		if(is_object($field)) $field = $field->getName();
615
616
		$i = 0;
617
		foreach($this->dataFields() as $child) {
618
			if($child->getName() == $field) return $i;
619
			$i++;
620
		}
621
622
		return false;
623
	}
624
625
	/**
626
	 * Ordered list of regular expressions