public function setQuery($query, $append = false)
    {
        if ($this->isStdObject($query)) {
            $query = $query->val();
        }

        if ($append && $this->query != '') {

            if ($this->isString($this->query)) {
                $currentQuery = new StringObject($this->query);
                $currentQuery = $currentQuery->parseString();
            } else {
                $currentQuery = new ArrayObject($this->query);
            }

            if ($this->isStdObject($query)) {
                if (StdObjectWrapper::isArrayObject($append)) {
                    $query = $query->val();
                } else {
                    if (StdObjectWrapper::isStringObject($query)) {
                        $query = $query->parseString()->val();
                    } else {
                        throw new UrlObjectException(UrlObjectException::MSG_INVALID_ARG, [
                                '$query',
                                'StringObject|ArrayObject|string|array'
                            ]
                        );
                    }
                }
            } else {
                if ($this->isString($query)) {
                    $query = new StringObject($query);
                    $query = $query->parseString()->val();
                }
            }

            $currentQuery->merge($query);
            $query = $currentQuery->val();
        }

        $this->query = $query;
        $this->rebuildUrl();

        return $this;
    }