/**
  * Attempts to connect to database.
  *
  * @return void
  * @throws \RuntimeException
  */
 private function connect()
 {
     $dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}";
     try {
         $pdo = new \PDO($dsn, $this->credentials->getUsername(), $this->credentials->getPassword());
     } catch (\PDOException $e) {
         throw new \RuntimeException('Failed to connect to database.', 0, $e);
     }
     $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     $pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
     $this->pdo = $pdo;
     if (!is_null($this->credentials->getCharset())) {
         $this->setCharset($this->credentials->getCharset());
     }
     if (!is_null($this->credentials->getDatabase())) {
         $this->selectDatabase($this->credentials->getDatabase());
     }
 }