Code Duplication    Length = 5-5 lines in 2 locations

src/ActiveQuery.php 1 location

@@ 304-308 (lines=5) @@
301
            $modelClass::populateRecord($model, $row);
302
            $this->populateJoinedRelations($model, $row);
303
            if ($this->indexBy) {
304
                if ($this->indexBy instanceof \Closure) {
305
                    $key = call_user_func($this->indexBy, $model);
306
                } else {
307
                    $key = $model->{$this->indexBy};
308
                }
309
                $models[$key] = $model;
310
            } else {
311
                $models[] = $model;

src/Query.php 1 location

@@ 95-99 (lines=5) @@
92
        if (!empty($rows) && $this->indexBy !== null) {
93
            $result = [];
94
            foreach ($rows as $row) {
95
                if ($this->indexBy instanceof \Closure) {
96
                    $key = call_user_func($this->indexBy, $row);
97
                } else {
98
                    $key = $row[$this->indexBy];
99
                }
100
                $result[$key] = $row;
101
            }
102
            $rows = $result;