public function getDsn()
    {
        if ($this->dsn) {
            return $this->dsn;
        }

        $dsn = $this->driver . ':';
        switch ($this->driver) {
            case 'mysql':
                $this->host && $dsn .= 'host=' . $this->host . ';';
                $this->port && $dsn .= 'port=' . $this->port . ';';
                $this->dbname && $dsn .= 'dbname=' . $this->dbname . ';';
                $this->unixSocket && $dsn .= 'unix_socket=' . $this->unixSocket . ';';
                $this->charset && $dsn .= 'charset=' . $this->charset;
                break;

            case 'sqlite':
                $dsn .= $this->path;
                break;

            case 'pgsql':
                $this->host && $dsn .= 'host=' . $this->host . ';';
                $this->port && $dsn .= 'port=' . $this->port . ';';
                $this->dbname && $dsn .= 'dbname=' . $this->dbname;
                break;

            default:
                throw new \RuntimeException(sprintf('Unsupported database driver: %s', $this->driver));
        }
        return $this->dsn = $dsn;
    }