protected function mergeOrReplaceQuery($query)
    {
        if (is_array($query)) {
            return array_merge($this->query, $query);
        }

        if (!is_string($query)) {
            throw new InvalidArgumentException('Query has to be array or string not '.gettype($query));
        }

        if ($query === '') {
            return [];
        }

        $normalized = ltrim($query, '?');

        $items = [];
        parse_str($normalized, $items);

        // If the query starts with a ? overwrite the complete url
        if ($query[0] == '?') {
            return $items;
        }

        return array_merge($this->query, $items);
    }
protected function mergeOrReplaceQuery($query)
    {
        if (is_array($query)) {
            return array_merge($this->query, $query);
        }

        if (!is_string($query)) {
            throw new InvalidArgumentException('Query has to be array or string not '.gettype($query));
        }

        if ($query === '') {
            return [];
        }

        $normalized = ltrim($query, '?');

        $items = [];
        parse_str($normalized, $items);

        // If the query starts with a ? overwrite the complete url
        if ($query[0] == '?') {
            return $items;
        }

        return array_merge($this->query, $items);
    }
protected function mergeOrReplaceQuery ( $ query ) { if ( is_array ( $ query ) ) { return array_merge ( $ this -> query , $ query ) ; } if ( ! is_string ( $ query ) ) { throw new InvalidArgumentException ( 'Query has to be array or string not ' . gettype ( $ query ) ) ; } if ( $ query === '' ) { return [ ] ; } $ normalized = ltrim ( $ query , '?' ) ; $ items = [ ] ; parse_str ( $ normalized , $ items ) ; // If the query starts with a ? overwrite the complete url if ( $ query [ 0 ] == '?' ) { return $ items ; } return array_merge ( $ this -> query , $ items ) ; }
Merges a new query or replace the current one if the query is a string
and starts with ?

@param string|array $query

@return array
Merges a new query or replace the current one if the query is a string and starts with ?