Code Duplication    Length = 26-26 lines in 2 locations

src/voku/db/Result.php 2 locations

@@ 904-929 (lines=26) @@
901
     * @return array
902
     *               <p>A grouped array of scalar values or arrays.</p>
903
     */
904
    public function &fetchGroups(string $group, string $column = null): array
905
    {
906
        // init
907
        $groups = [];
908
        $pos = $this->current_row;
909
910
        foreach ($this->fetchAllArrayyYield() as $row) {
911
            if (!\array_key_exists($group, $row)) {
912
                continue;
913
            }
914
915
            if ($column !== null) {
916
                if (!\array_key_exists($column, $row)) {
917
                    continue;
918
                }
919
920
                $groups[$row[$group]][] = $row[$column];
921
            } else {
922
                $groups[$row[$group]][] = $row;
923
            }
924
        }
925
926
        $this->rewind($pos);
927
928
        return $groups;
929
    }
930
931
    /**
932
     * Fetch as object.
@@ 1012-1037 (lines=26) @@
1009
     * @return array
1010
     *               <p>An array of key-value pairs.</p>
1011
     */
1012
    public function fetchPairs(string $key, string $column = null): array
1013
    {
1014
        // init
1015
        $pairs = [];
1016
        $pos = $this->current_row;
1017
1018
        foreach ($this->fetchAllArrayyYield() as $row) {
1019
            if (!\array_key_exists($key, $row)) {
1020
                continue;
1021
            }
1022
1023
            if ($column !== null) {
1024
                if (!\array_key_exists($column, $row)) {
1025
                    continue;
1026
                }
1027
1028
                $pairs[$row[$key]] = $row[$column];
1029
            } else {
1030
                $pairs[$row[$key]] = $row;
1031
            }
1032
        }
1033
1034
        $this->rewind($pos);
1035
1036
        return $pairs;
1037
    }
1038
1039
    /**
1040
     * Returns all rows at once, transposed as an array of arrays. Instead of