client = $client; $this->dbName = $dbName; } public function client(): Client { return $this->client; } public function dbName(): string { return $this->dbName; } public function selectCollection(string $collectionName, array $options = []): Collection { return $this->client->selectCollection($this->dbName, $collectionName, $options); } public function replaceCollection(string $collectionName, string $withCollection) { $adminDb = $this->client->admin; $cursor = $adminDb->command([ 'renameCollection' => $this->dbName . '.' . $withCollection, 'to' => $this->dbName . '.' . $collectionName, 'dropTarget' => true ]); return current($cursor->toArray()); } }