public function open()
    {
        if ($this->isConnected()) {
            throw new ConnectionEstablishedException;
        }

        $stream = $this->doConnect();

        if (false === $stream) {
            throw new ConnectionException(sprintf("Could not connect to server %s:%s", $this->getHost(), $this->getPort()));
        }

        if (!@ftp_login($stream, $this->getUsername(), $this->getPassword())) {
            throw new ConnectionException(sprintf(
                "Could not login using combination of username (%s) and password (%s)",
                $this->getUsername(),
                preg_replace("/./", "*", $this->getPassword())
            ));
        }

        if (true === $this->passive) {
            if (false === ftp_pasv($stream, true)) {
                throw new ConnectionException("Cold not turn on passive mode");
            }
        }

        $this->connected = true;
        $this->stream    = $stream;

        return true;
    }