Code Duplication    Length = 26-28 lines in 2 locations

src/Queries/ElementQuery.php 1 location

@@ 141-166 (lines=26) @@
138
     *
139
     * @return Collection
140
     */
141
    public function getList()
142
    {
143
        if ($this->queryShouldBeStopped) {
144
            return new Collection();
145
        }
146
147
        $sort = $this->sort;
148
        $filter = $this->normalizeFilter();
149
        $groupBy = $this->groupBy;
150
        $navigation = $this->navigation;
151
        $select = $this->normalizeSelect();
152
        $queryType = 'ElementQuery::getList';
153
        $keyBy = $this->keyBy;
154
155
        $callback = function() use ($sort, $filter, $groupBy, $navigation, $select) {
156
            $items = [];
157
            $rsItems = $this->bxObject->GetList($sort, $filter, $groupBy, $navigation, $select);
158
            while ($arItem = $rsItems->Fetch()) {
159
                $this->addItemToResultsUsingKeyBy($items, new $this->modelName($arItem['ID'], $arItem));
160
            }
161
162
            return new Collection($items);
163
        };
164
165
        return $this->handleCacheIfNeeded(compact('sort', 'filter', 'group', 'navigation', 'select', 'queryType', 'keyBy'), $callback);
166
    }
167
168
    /**
169
     * Get the first element with a given code.

src/Queries/SectionQuery.php 1 location

@@ 83-110 (lines=28) @@
80
     *
81
     * @return Collection
82
     */
83
    public function getList()
84
    {
85
        if ($this->queryShouldBeStopped) {
86
            return new Collection();
87
        }
88
89
        $queryType = 'SectionQuery::getList';
90
        $sort = $this->sort;
91
        $filter = $this->normalizeFilter();
92
        $countElements = $this->countElements;
93
        $select = $this->normalizeSelect();
94
        $navigation = $this->navigation;
95
        $keyBy = $this->keyBy;
96
97
        $callback = function() use ($sort, $filter, $countElements, $select, $navigation){
98
            $sections = [];
99
            $rsSections = $this->bxObject->getList($sort, $filter, $countElements, $select, $navigation);
100
            while ($arSection = $rsSections->Fetch()) {
101
                $this->addItemToResultsUsingKeyBy($sections, new $this->modelName($arSection['ID'], $arSection));
102
            }
103
104
            return new Collection($sections);
105
        };
106
107
        $cacheParams = compact('queryType', 'sort', 'filter', 'countElements', 'select', 'navigation', 'keyBy');
108
109
        return $this->handleCacheIfNeeded($cacheParams, $callback);
110
    }
111
112
    /**
113
     * Get the first section with a given code.