Code Duplication    Length = 5-5 lines in 2 locations

src/ActiveQuery.php 1 location

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

src/Query.php 1 location

@@ 80-84 (lines=5) @@
77
        if (!empty($rows) && $this->indexBy !== null) {
78
            $result = [];
79
            foreach ($rows as $row) {
80
                if ($this->indexBy instanceof \Closure) {
81
                    $key = call_user_func($this->indexBy, $row);
82
                } else {
83
                    $key = $row[$this->indexBy];
84
                }
85
                $result[$key] = $row;
86
            }
87
            $rows = $result;