Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/Result.php 2 locations

@@ 900-927 (lines=28) @@
897
     * @return array
898
     *               <p>A grouped array of scalar values or arrays.</p>
899
     */
900
    public function fetchGroups(string $group, string $column = null): array
901
    {
902
        // init
903
        $groups = [];
904
        $pos = $this->current_row;
905
906
        foreach ($this as $row) {
907
            if (!\array_key_exists($group, $row)) {
908
                continue;
909
            }
910
911
            if ($column !== null) {
912
                if (!\array_key_exists($column, $row)) {
913
                    continue;
914
                }
915
916
                $groups[$row[$group]][] = $row[$column];
917
            } else {
918
                $groups[$row[$group]][] = $row;
919
            }
920
        }
921
922
        $this->rewind($pos);
923
924
        return $groups;
925
    }
926
927
    /**
928
     * Fetch as object.
929
     *
930
     * @param object|string $class  <p>
@@ 993-1020 (lines=28) @@
990
     * @return array
991
     *               <p>An array of key-value pairs.</p>
992
     */
993
    public function fetchPairs(string $key, string $column = null): array
994
    {
995
        // init
996
        $pairs = [];
997
        $pos = $this->current_row;
998
999
        foreach ($this as $row) {
1000
            if (!\array_key_exists($key, $row)) {
1001
                continue;
1002
            }
1003
1004
            if ($column !== null) {
1005
                if (!\array_key_exists($column, $row)) {
1006
                    continue;
1007
                }
1008
1009
                $pairs[$row[$key]] = $row[$column];
1010
            } else {
1011
                $pairs[$row[$key]] = $row;
1012
            }
1013
        }
1014
1015
        $this->rewind($pos);
1016
1017
        return $pairs;
1018
    }
1019
1020
    /**
1021
     * Returns all rows at once, transposed as an array of arrays. Instead of
1022
     * returning rows of columns, this method returns columns of rows.
1023
     *