ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ArrayInputData.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use LogicException;
25 
29 class ArrayInputData implements InputData
30 {
31  protected array $data;
32 
33  public function __construct(array $data)
34  {
35  $this->data = $data;
36  }
37 
38  public function get($name)
39  {
40  if (!$this->has($name)) {
41  throw new LogicException("'$name' is not contained in provided data.");
42  }
43 
44  return $this->data[$name];
45  }
46 
47  public function getOr($name, $default)
48  {
49  return $this->data[$name] ?? $default;
50  }
51 
52  public function has($name): bool
53  {
54  return array_key_exists($name, $this->data);
55  }
56 }
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:29
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...