Code Duplication    Length = 5-5 lines in 2 locations

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;

src/ActiveQuery.php 1 location

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