public function toArray($parts = self::FULL, $escape = null)
    {
        $result = array();
        $escape = isset($escape) ? (bool) $escape : $this->isEscaped();

        if (($parts & self::SCHEME) && !empty($this->scheme)) {
            $result['scheme'] = $this->scheme;
        }

        if (($parts & self::USER) && !empty($this->user)) {
            $result['user'] = $this->user;
        }

        if (($parts & self::PASS) && !empty($this->pass)) {
            $result['user'] = $this->pass;
        }

        if (($parts & self::PORT) && !empty($this->port)) {
            $result['port'] = $this->port;
        }

        if (($parts & self::HOST) && !empty($this->host)) {
            $result['host'] = $this->host;
        }

        if (($parts & self::PATH) && !empty($this->_path)) {
            $result['path'] = $this->_path;
        }

        if (($parts & self::QUERY) && !empty($this->_query)) {
            $result['query'] = $this->getQuery(false, $escape);
        }

        if (($parts & self::FRAGMENT) && trim($this->fragment) !== '') {
            $result['fragment'] = $this->fragment;
        }

        return $result;
    }