diff --git a/src/Client.php b/src/Client.php index 748124960f..9d7884fa19 100644 --- a/src/Client.php +++ b/src/Client.php @@ -228,6 +228,16 @@ class Client return $this; } + /** + * Return client's host + * + * @return string + */ + public function getHost(): string + { + return $this->host; + } + /** * Create a UUID using UUID7 standard for MongoDB _id field. * diff --git a/tests/MongoTest.php b/tests/MongoTest.php index 2d4871647e..02d739ad2f 100644 --- a/tests/MongoTest.php +++ b/tests/MongoTest.php @@ -41,6 +41,10 @@ class MongoTest extends TestCase self::assertTrue($this->getDatabase()->dropDatabase()); } + public function testGetHost() + { + self::assertSame('mongo', $this->getDatabase()->getClusterTime()); + } /** * @throws Exception