Code Duplication    Length = 31-31 lines in 4 locations

lib/Command/Index.php 2 locations

@@ 723-753 (lines=31) @@
720
	 * @throw OutOfBoundsException
721
	 * @return array
722
	 */
723
	private function getNavigationError(int $pos, bool $isFirst, bool $isLast): array {
724
725
		if ($pos === 0) {
726
			if ($this->navigateLastError === true) {
727
				return end($this->errors);
728
			} else {
729
				return current($this->errors);
730
			}
731
		}
732
733
		$this->navigateLastError = false;
734
		if ($pos === -99) {
735
			return reset($this->errors);
736
		}
737
738
		if ($pos === -1 && !$isFirst) {
739
			return prev($this->errors);
740
		}
741
742
		if ($pos === 1 && !$isLast) {
743
			return next($this->errors);
744
		}
745
746
		if ($pos === 99) {
747
			$this->navigateLastError = true;
748
749
			return end($this->errors);
750
		}
751
752
		throw new OutOfBoundsException();
753
	}
754
755
756
	/**
@@ 764-794 (lines=31) @@
761
	 * @throw OutOfBoundsException
762
	 * @return array
763
	 */
764
	private function getNavigationResult(int $pos, bool $isFirst, bool $isLast): array {
765
766
		if ($pos === 0) {
767
			if ($this->navigateLastResult === true) {
768
				return end($this->results);
769
			} else {
770
				return current($this->results);
771
			}
772
		}
773
774
		$this->navigateLastResult = false;
775
		if ($pos === -99) {
776
			return reset($this->results);
777
		}
778
779
		if ($pos === -1 && !$isFirst) {
780
			return prev($this->results);
781
		}
782
783
		if ($pos === 1 && !$isLast) {
784
			return next($this->results);
785
		}
786
787
		if ($pos === 99) {
788
			$this->navigateLastResult = true;
789
790
			return end($this->results);
791
		}
792
793
		throw new OutOfBoundsException();
794
	}
795
796
797
	/**

lib/Command/Live.php 2 locations

@@ 638-668 (lines=31) @@
635
	 * @return array
636
	 * @throws OutOfBoundsException
637
	 */
638
	private function getNavigationResult(int $pos, bool $isFirst, bool $isLast): array {
639
640
		if ($pos === 0) {
641
			if ($this->navigateLastResult === true) {
642
				return end($this->results);
643
			} else {
644
				return current($this->results);
645
			}
646
		}
647
648
		$this->navigateLastResult = false;
649
		if ($pos === -99) {
650
			return reset($this->results);
651
		}
652
653
		if ($pos === -1 && !$isFirst) {
654
			return prev($this->results);
655
		}
656
657
		if ($pos === 1 && !$isLast) {
658
			return next($this->results);
659
		}
660
661
		if ($pos === 99) {
662
			$this->navigateLastResult = true;
663
664
			return end($this->results);
665
		}
666
667
		throw new OutOfBoundsException();
668
	}
669
670
671
	/**
@@ 678-708 (lines=31) @@
675
	 *
676
	 * @return array
677
	 */
678
	private function getNavigationError(int $pos, bool $isFirst, bool $isLast): array {
679
680
		if ($pos === 0) {
681
			if ($this->navigateLastError === true) {
682
				return end($this->errors);
683
			} else {
684
				return current($this->errors);
685
			}
686
		}
687
688
		$this->navigateLastError = false;
689
		if ($pos === -99) {
690
			return reset($this->errors);
691
		}
692
693
		if ($pos === -1 && !$isFirst) {
694
			return prev($this->errors);
695
		}
696
697
		if ($pos === 1 && !$isLast) {
698
			return next($this->errors);
699
		}
700
701
		if ($pos === 99) {
702
			$this->navigateLastError = true;
703
704
			return end($this->errors);
705
		}
706
707
		throw new OutOfBoundsException();
708
	}
709
710
711
	/**