Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

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