ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PostDataFromServerRequest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Psr\Http\Message\ServerRequestInterface;
24use LogicException;
26
32{
33 protected array $parsed_body;
34
35 public function __construct(ServerRequestInterface $request)
36 {
37 $this->parsed_body = $request->getParsedBody();
38 }
39
43 public function get(string $name)
44 {
45 if (!isset($this->parsed_body[$name])) {
46 throw new LogicException("'$name' is not contained in posted data.");
47 }
48
49 return $this->parsed_body[$name];
50 }
51
52
56 public function getOr(string $name, $default)
57 {
58 if (!isset($this->parsed_body[$name])) {
59 return $default;
60 }
61
62 return $this->parsed_body[$name];
63 }
64
65 public function has($name): bool
66 {
67 return array_key_exists($name, $this->parsed_body);
68 }
69}
Implements interaction of input element with post 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...