ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTMultiEnumDefinition.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected array $options = [];
24 protected bool $numeric = false;
25
26 // default
27
28 public function reset(): void
29 {
30 parent::reset();
31
32 $this->options = array();
33 $this->setNumeric(true);
34 }
35
36 public function getOptions(): array
37 {
38 return $this->options;
39 }
40
41 public function setOptions(array $a_values): void
42 {
43 if ($this->isNumeric()) {
44 foreach (array_keys($a_values) as $key) {
45 if (!is_numeric($key)) {
46 throw new InvalidArgumentException("ilADTMultiEnum was expecting numeric option keys");
47 }
48 }
49 }
50 $this->options = $a_values;
51 }
52
53 public function isNumeric(): bool
54 {
55 return $this->numeric;
56 }
57
58 public function setNumeric(bool $a_value): void
59 {
60 $this->numeric = $a_value;
61 }
62
63 public function isComparableTo(ilADT $a_adt): bool
64 {
65 return ($a_adt instanceof ilADTMultiEnum);
66 }
67
68 // ADT instance
69
70 public function getADTInstance(): ilADT
71 {
72 if ($this->isNumeric()) {
73 $class = "ilADTMultiEnumNumeric";
74 } else {
75 $class = "ilADTMultiEnumText";
76 }
77 return new $class($this);
78 }
79}
ADT definition base class.
isComparableTo(ilADT $a_adt)
Check if given ADT is comparable to self.
ADT base class.
Definition: class.ilADT.php:26