Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

@@ 854-881 (lines=28) @@
851
     *
852
     * @return array A grouped array of scalar values or arrays
853
     */
854
    public function fetchGroups(string $group, string $column = null): array
855
    {
856
        // init
857
        $groups = [];
858
        $pos = $this->current_row;
859
860
        foreach ($this as $row) {
861
            if (!\array_key_exists($group, $row)) {
862
                continue;
863
            }
864
865
            if ($column !== null) {
866
                if (!\array_key_exists($column, $row)) {
867
                    continue;
868
                }
869
870
                $groups[$row[$group]][] = $row[$column];
871
            } else {
872
                $groups[$row[$group]][] = $row;
873
            }
874
        }
875
876
        $this->rewind($pos);
877
878
        return $groups;
879
    }
880
881
    /**
882
     * Fetch as object.
883
     *
884
     * @param object|string $class  <p>
@@ 946-973 (lines=28) @@
943
     *
944
     * @return array An array of key-value pairs
945
     */
946
    public function fetchPairs(string $key, string $column = null): array
947
    {
948
        // init
949
        $pairs = [];
950
        $pos = $this->current_row;
951
952
        foreach ($this as $row) {
953
            if (!\array_key_exists($key, $row)) {
954
                continue;
955
            }
956
957
            if ($column !== null) {
958
                if (!\array_key_exists($column, $row)) {
959
                    continue;
960
                }
961
962
                $pairs[$row[$key]] = $row[$column];
963
            } else {
964
                $pairs[$row[$key]] = $row;
965
            }
966
        }
967
968
        $this->rewind($pos);
969
970
        return $pairs;
971
    }
972
973
    /**
974
     * Returns all rows at once, transposed as an array of arrays. Instead of
975
     * returning rows of columns, this method returns columns of rows.
976
     *