getQuery() ? [] : array_reduce( explode('&', $uri->getQuery()), function ($carry, $item) { list($key, $value) = explode('=', $item, 2); $carry[rawurldecode($key)] = rawurldecode($value); return $carry; }, [] ); foreach (array_merge($queryStringData, $params) as $key => $value) { $signatureData[rawurlencode($key)] = rawurlencode($value); } ksort($signatureData); // determine base uri $baseUri = $uri->getScheme() . '://' . $uri->getRawAuthority(); if ('/' == $uri->getPath()) { $baseUri .= $uri->hasExplicitTrailingHostSlash() ? '/' : ''; } else { $baseUri .= $uri->getPath(); } $baseString = strtoupper($method) . '&'; $baseString .= rawurlencode($baseUri) . '&'; $baseString .= rawurlencode($this->buildSignatureDataString($signatureData)); return base64_encode($this->hash($baseString)); } }