Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

@@ 700-727 (lines=28) @@
697
   *
698
   * @return array A grouped array of scalar values or arrays
699
   */
700
  public function fetchGroups(string $group, string $column = null): array
701
  {
702
    // init
703
    $groups = [];
704
    $pos = $this->current_row;
705
706
    foreach ($this as $row) {
707
708
      if (!\array_key_exists($group, $row)) {
709
        continue;
710
      }
711
712
      if (null !== $column) {
713
714
        if (!\array_key_exists($column, $row)) {
715
          continue;
716
        }
717
718
        $groups[$row[$group]][] = $row[$column];
719
      } else {
720
        $groups[$row[$group]][] = $row;
721
      }
722
    }
723
724
    $this->rewind($pos);
725
726
    return $groups;
727
  }
728
729
  /**
730
   * Returns all rows at once as key-value pairs.
@@ 737-764 (lines=28) @@
734
   *
735
   * @return array An array of key-value pairs
736
   */
737
  public function fetchPairs(string $key, string $column = null): array
738
  {
739
    // init
740
    $pairs = [];
741
    $pos = $this->current_row;
742
743
    foreach ($this as $row) {
744
745
      if (!\array_key_exists($key, $row)) {
746
        continue;
747
      }
748
749
      if (null !== $column) {
750
751
        if (!\array_key_exists($column, $row)) {
752
          continue;
753
        }
754
755
        $pairs[$row[$key]] = $row[$column];
756
      } else {
757
        $pairs[$row[$key]] = $row;
758
      }
759
    }
760
761
    $this->rewind($pos);
762
763
    return $pairs;
764
  }
765
766
  /**
767
   * Returns all rows at once, transposed as an array of arrays. Instead of