Code Duplication    Length = 17-17 lines in 2 locations

framework/Web/UI/WebControls/TDataGrid.php 1 location

@@ 571-587 (lines=17) @@
568
	 * If the index is less than 0, any existing edit item will be cleared up.
569
	 * @param int $value the edit item index
570
	 */
571
	public function setEditItemIndex($value)
572
	{
573
		if (($value = TPropertyValue::ensureInteger($value)) < 0) {
574
			$value = -1;
575
		}
576
		if (($current = $this->getEditItemIndex()) !== $value) {
577
			$this->setViewState('EditItemIndex', $value, -1);
578
			$items = $this->getItems();
579
			$itemCount = $items->getCount();
580
			if ($current >= 0 && $current < $itemCount) {
581
				$items->itemAt($current)->setItemType($current % 2 ? TListItemType::AlternatingItem : TListItemType::Item);
582
			}
583
			if ($value >= 0 && $value < $itemCount) {
584
				$items->itemAt($value)->setItemType(TListItemType::EditItem);
585
			}
586
		}
587
	}
588
589
	/**
590
	 * @return bool whether sorting is enabled. Defaults to false.

framework/Web/UI/WebControls/TDataList.php 1 location

@@ 754-770 (lines=17) @@
751
	 * If the index is less than 0, any existing edit item will be cleared up.
752
	 * @param int $value the edit item index
753
	 */
754
	public function setEditItemIndex($value)
755
	{
756
		if (($value = TPropertyValue::ensureInteger($value)) < 0) {
757
			$value = -1;
758
		}
759
		if (($current = $this->getEditItemIndex()) !== $value) {
760
			$this->setViewState('EditItemIndex', $value, -1);
761
			$items = $this->getItems();
762
			$itemCount = $items->getCount();
763
			if ($current >= 0 && $current < $itemCount) {
764
				$items->itemAt($current)->setItemType($current % 2 ? TListItemType::AlternatingItem : TListItemType::Item);
765
			}
766
			if ($value >= 0 && $value < $itemCount) {
767
				$items->itemAt($value)->setItemType(TListItemType::EditItem);
768
			}
769
		}
770
	}
771
772
	/**
773
	 * @return TControl the edit item