ILIAS  release_7 Revision v7.30-3-g800a261c036
QueryParamsFromServerRequest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Thomas Famula <famula@leifos.de> Extended GPL, see docs/LICENSE */
4
6
8use Psr\Http\Message\ServerRequestInterface;
9
15{
16
20 protected $query_params;
21
22
23 public function __construct(ServerRequestInterface $request)
24 {
25 $this->query_params = $request->getQueryParams();
26 }
27
28
32 public function get($name)
33 {
34 if (!isset($this->query_params[$name])) {
35 throw new \LogicException("'$name' is not contained in query parameters.");
36 }
37
38 return $this->query_params[$name];
39 }
40
41
45 public function getOr($name, $default)
46 {
47 if (!isset($this->query_params[$name])) {
48 return $default;
49 }
50
51 return $this->query_params[$name];
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
Implements interaction of input element with get data from psr-7 server request.
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:13
if($format !==null) $name
Definition: metadata.php:230