Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

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