protected static function parseQuery($query)
    {
        if (is_array($query))
            return $query;

        if (empty($query))
            return null;

        if (!is_string($query))
            throw new \InvalidArgumentException('Query must be associative array or string');
        
        $query = ltrim($query, '?');
        $query = str_replace('&amp;', '&', $query);
        $parts = explode('&', $query);
        $values = [];
        foreach ($parts as $part)
        {
            $subparts = explode('=', $part, 2);
            if (count($subparts) === 1)
                $values[$part] = '1';
            else
                $values[$subparts[0]] = $subparts[1];
        }

        return empty($values) ? null : $values;
    }
protected static function parseQuery($query)
    {
        if (is_array($query))
            return $query;

        if (empty($query))
            return null;

        if (!is_string($query))
            throw new \InvalidArgumentException('Query must be associative array or string');
        
        $query = ltrim($query, '?');
        $query = str_replace('&amp;', '&', $query);
        $parts = explode('&', $query);
        $values = [];
        foreach ($parts as $part)
        {
            $subparts = explode('=', $part, 2);
            if (count($subparts) === 1)
                $values[$part] = '1';
            else
                $values[$subparts[0]] = $subparts[1];
        }

        return empty($values) ? null : $values;
    }
protected static function parseQuery ( $ query ) { if ( is_array ( $ query ) ) return $ query ; if ( empty ( $ query ) ) return null ; if ( ! is_string ( $ query ) ) throw new \ InvalidArgumentException ( 'Query must be associative array or string' ) ; $ query = ltrim ( $ query , '?' ) ; $ query = str_replace ( '&amp;' , '&' , $ query ) ; $ parts = explode ( '&' , $ query ) ; $ values = [ ] ; foreach ( $ parts as $ part ) { $ subparts = explode ( '=' , $ part , 2 ) ; if ( count ( $ subparts ) === 1 ) $ values [ $ part ] = '1' ; else $ values [ $ subparts [ 0 ] ] = $ subparts [ 1 ] ; } return empty ( $ values ) ? null : $ values ; }
Parse a query string or array
@param string|array $query The query to parse
@return array The associative array of key/value pairs. If an array was passed in,
it is returned as-is.
Parse a query string or array