ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
PostDataFromServerRequest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
24 use LogicException;
25 
31 {
32  protected array $parsed_body;
33 
34  public function __construct(ServerRequestInterface $request)
35  {
36  $this->parsed_body = $request->getParsedBody();
37  }
38 
42  public function get(string $name)
43  {
44  if (!isset($this->parsed_body[$name])) {
45  throw new LogicException("'$name' is not contained in posted data.");
46  }
47 
48  return $this->parsed_body[$name];
49  }
50 
51 
55  public function getOr(string $name, $default)
56  {
57  if (!isset($this->parsed_body[$name])) {
58  return $default;
59  }
60 
61  return $this->parsed_body[$name];
62  }
63 
64  public function has($name): bool
65  {
66  return array_key_exists($name, $this->parsed_body);
67  }
68 }
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:29
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...