private function _indexBy($list, $property) { $newList = []; foreach ($list as $item) { $newList[$item->{$property}] = $item; } return $newList; }