Open Journal Systems  3.3.0
QueryParam.php
1 <?php
2 
4 
7 
16 final class QueryParam implements Authentication
17 {
21  private $params = [];
22 
26  public function __construct(array $params)
27  {
28  $this->params = $params;
29  }
30 
34  public function authenticate(RequestInterface $request)
35  {
36  $uri = $request->getUri();
37  $query = $uri->getQuery();
38  $params = [];
39 
40  parse_str($query, $params);
41 
42  $params = array_merge($params, $this->params);
43 
44  $query = http_build_query($params, null, '&');
45 
46  $uri = $uri->withQuery($query);
47 
48  return $request->withUri($uri);
49  }
50 }
Http\Message\Authentication\QueryParam\authenticate
authenticate(RequestInterface $request)
Definition: QueryParam.php:37
Http\Message\Authentication
Definition: AutoBasicAuth.php:3
Psr\Http\Message\RequestInterface
Definition: vendor/psr/http-message/src/RequestInterface.php:24
Http\Message\Authentication
Definition: Authentication.php:12
Http\Message\Authentication\QueryParam
Definition: QueryParam.php:16
Psr\Http\Message\RequestInterface\withUri
withUri(UriInterface $uri, $preserveHost=false)
Psr\Http\Message\RequestInterface\getUri
getUri()
Http\Message\Authentication\QueryParam\__construct
__construct(array $params)
Definition: QueryParam.php:29