ILIAS  release_8 Revision v8.23
class.ilADTMultiEnumDefinition.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 {
7  protected array $options = [];
8  protected bool $numeric = false;
9 
10  // default
11 
12  public function reset(): void
13  {
14  parent::reset();
15 
16  $this->options = array();
17  $this->setNumeric(true);
18  }
19 
20  public function getOptions(): array
21  {
22  return $this->options;
23  }
24 
25  public function setOptions(array $a_values): void
26  {
27  if ($this->isNumeric()) {
28  foreach (array_keys($a_values) as $key) {
29  if (!is_numeric($key)) {
30  throw new InvalidArgumentException("ilADTMultiEnum was expecting numeric option keys");
31  }
32  }
33  }
34  $this->options = $a_values;
35  }
36 
37  public function isNumeric(): bool
38  {
39  return $this->numeric;
40  }
41 
42  public function setNumeric(bool $a_value): void
43  {
44  $this->numeric = $a_value;
45  }
46 
47  public function isComparableTo(ilADT $a_adt): bool
48  {
49  return ($a_adt instanceof ilADTMultiEnum);
50  }
51 
52  // ADT instance
53 
54  public function getADTInstance(): ilADT
55  {
56  if ($this->isNumeric()) {
57  $class = "ilADTMultiEnumNumeric";
58  } else {
59  $class = "ilADTMultiEnumText";
60  }
61  return new $class($this);
62  }
63 }
ADT base class.
Definition: class.ilADT.php:11
string $key
Consumer key/client ID value.
Definition: System.php:193
ADT definition base class.