Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

@@ 642-669 (lines=28) @@
639
   *
640
   * @return array A grouped array of scalar values or arrays
641
   */
642
  public function fetchGroups($group, $column = null)
643
  {
644
    // init
645
    $groups = array();
646
    $pos = $this->current_row;
647
648
    foreach ($this as $row) {
649
650
      if (!array_key_exists($group, $row)) {
651
        continue;
652
      }
653
654
      if (isset($column)) {
655
656
        if (!array_key_exists($column, $row)) {
657
          continue;
658
        }
659
660
        $groups[$row[$group]][] = $row[$column];
661
      } else {
662
        $groups[$row[$group]][] = $row;
663
      }
664
    }
665
666
    $this->rewind($pos);
667
668
    return $groups;
669
  }
670
671
  /**
672
   * Returns all rows at once as key-value pairs.
@@ 679-706 (lines=28) @@
676
   *
677
   * @return array An array of key-value pairs
678
   */
679
  public function fetchPairs($key, $column = null)
680
  {
681
    // init
682
    $pairs = array();
683
    $pos = $this->current_row;
684
685
    foreach ($this as $row) {
686
687
      if (!array_key_exists($key, $row)) {
688
        continue;
689
      }
690
691
      if (isset($column)) {
692
693
        if (!array_key_exists($column, $row)) {
694
          continue;
695
        }
696
697
        $pairs[$row[$key]] = $row[$column];
698
      } else {
699
        $pairs[$row[$key]] = $row;
700
      }
701
    }
702
703
    $this->rewind($pos);
704
705
    return $pairs;
706
  }
707
708
  /**
709
   * Returns all rows at once, transposed as an array of arrays. Instead of