public function __construct(Client $client, $database) { $this->client = $client; if ($database instanceof \MongoDB) { $this->mongoDB = $database; } else { $this->mongoDB = $this->client->getMongoClient()->selectDB($database); } }
/** * * @return \MongoDB */ public function getMongoDB() { if (empty($this->database)) { $this->database = $this->client->getMongoClient()->selectDB($this->databaseName); } return $this->database; }