Code Duplication    Length = 5-5 lines in 2 locations

src/ActiveQuery.php 1 location

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

src/Query.php 1 location

@@ 85-89 (lines=5) @@
82
        if (!empty($rows) && $this->indexBy !== null) {
83
            $result = [];
84
            foreach ($rows as $row) {
85
                if ($this->indexBy instanceof \Closure) {
86
                    $key = call_user_func($this->indexBy, $row);
87
                } else {
88
                    $key = $row[$this->indexBy];
89
                }
90
                $result[$key] = $row;
91
            }
92
            $rows = $result;