src/Validator/MongoDbConnection.php
public function isValid($value)
    {
        $this->databaseError = null;

        // @codeCoverageIgnoreStart
        // This cannot be testes until we have a test database environment.
        try {
            $connection = new Client($value);
            $connection->listDatabases();
        } catch (ConnectionTimeoutException $e) {
            $this->databaseError = $e->getMessage();
            $this->error(self::NO_CONNECTION);
            return false;
        } catch (\Exception $e) {
            $this->databaseError = $e->getMessage();
            $this->error(self::NO_CONNECTION);
            return false;
        }

        return true;
        // @codeCoverageIgnoreEnd
    }
public function isValid($value)
    {
        $this->databaseError = null;

        // @codeCoverageIgnoreStart
        // This cannot be testes until we have a test database environment.
        try {
            $connection = new Client($value);
            $connection->listDatabases();
        } catch (ConnectionTimeoutException $e) {
            $this->databaseError = $e->getMessage();
            $this->error(self::NO_CONNECTION);
            return false;
        } catch (\Exception $e) {
            $this->databaseError = $e->getMessage();
            $this->error(self::NO_CONNECTION);
            return false;
        }

        return true;
        // @codeCoverageIgnoreEnd
    }
public function isValid ( $ value ) { $ this -> databaseError = null ; // @codeCoverageIgnoreStart // This cannot be testes until we have a test database environment. try { $ connection = new Client ( $ value ) ; $ connection -> listDatabases ( ) ; } catch ( ConnectionTimeoutException $ e ) { $ this -> databaseError = $ e -> getMessage ( ) ; $ this -> error ( self :: NO_CONNECTION ) ; return false ; } catch ( \ Exception $ e ) { $ this -> databaseError = $ e -> getMessage ( ) ; $ this -> error ( self :: NO_CONNECTION ) ; return false ; } return true ; // @codeCoverageIgnoreEnd }
Returns true if and only if a mongodb connection can be established.

@param  string $value The mongodb connection string

@return bool
Returns true if and only if a mongodb connection can be established .