ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
QueryParamsFromServerRequest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use Psr\Http\Message\ServerRequestInterface;
25use LogicException;
26
31{
32 protected array $query_params;
33
34 public function __construct(ServerRequestInterface $request)
35 {
36 $this->query_params = $request->getQueryParams();
37 }
38
42 public function get(string $name)
43 {
44 if (!isset($this->query_params[$name])) {
45 throw new LogicException("'$name' is not contained in query parameters.");
46 }
47
48 return $this->query_params[$name];
49 }
50
54 public function getOr(string $name, $default)
55 {
56 if (!isset($this->query_params[$name])) {
57 return $default;
58 }
59
60 return $this->query_params[$name];
61 }
62
66 public function has($name): bool
67 {
68 return array_key_exists($name, $this->query_params);
69 }
70}
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:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...