Code Duplication    Length = 31-31 lines in 4 locations

lib/Command/Index.php 2 locations

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

lib/Command/Live.php 2 locations

@@ 659-689 (lines=31) @@
656
	 * @return array
657
	 * @throws OutOfBoundsException
658
	 */
659
	private function getNavigationResult(int $pos, bool $isFirst, bool $isLast): array {
660
661
		if ($pos === 0) {
662
			if ($this->navigateLastResult === true) {
663
				return end($this->results);
664
			} else {
665
				return current($this->results);
666
			}
667
		}
668
669
		$this->navigateLastResult = false;
670
		if ($pos === -99) {
671
			return reset($this->results);
672
		}
673
674
		if ($pos === -1 && !$isFirst) {
675
			return prev($this->results);
676
		}
677
678
		if ($pos === 1 && !$isLast) {
679
			return next($this->results);
680
		}
681
682
		if ($pos === 99) {
683
			$this->navigateLastResult = true;
684
685
			return end($this->results);
686
		}
687
688
		throw new OutOfBoundsException();
689
	}
690
691
692
	/**
@@ 699-729 (lines=31) @@
696
	 *
697
	 * @return array
698
	 */
699
	private function getNavigationError(int $pos, bool $isFirst, bool $isLast): array {
700
701
		if ($pos === 0) {
702
			if ($this->navigateLastError === true) {
703
				return end($this->errors);
704
			} else {
705
				return current($this->errors);
706
			}
707
		}
708
709
		$this->navigateLastError = false;
710
		if ($pos === -99) {
711
			return reset($this->errors);
712
		}
713
714
		if ($pos === -1 && !$isFirst) {
715
			return prev($this->errors);
716
		}
717
718
		if ($pos === 1 && !$isLast) {
719
			return next($this->errors);
720
		}
721
722
		if ($pos === 99) {
723
			$this->navigateLastError = true;
724
725
			return end($this->errors);
726
		}
727
728
		throw new OutOfBoundsException();
729
	}
730
731
732
	/**