/** * Checks whether the connection is initialized and connected. * * @return boolean */ public function isConnected() { if (!($this->mongoClient instanceof \MongoClient || $this->mongoClient instanceof \Mongo)) { return false; } return count($this->mongoClient->getHosts()) > 0; }