private function login()
    {
        if (empty($this->host)) {
            throw new RuntimeException('no host to connect to');
        }

        $old  = error_reporting(0);
        $link = $this->isSecure
              ? ftp_ssl_connect($this->host, $this->port)
              : ftp_connect($this->host, $this->port);

        if (!$link) {
            error_reporting($old);
            throw new RuntimeException(sprintf('unable to connect to ftp server %s', $this->host));
        }

        $this->connection = $link;
        if (!ftp_login($this->connection, $this->user, $this->password)) {
            error_reporting($old);
            throw new RuntimeException(
                sprintf('authentication failed for %s@%s', $this->user, $this->host)
            );
        }
        // set passive mode if needed
        $this->pasv($this->passive);
        error_reporting($old);
    }