ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilADTEnumDefinition.php
Go to the documentation of this file.
1<?php
2
4{
5 protected $options = []; // [array]
6 protected $numeric; // [bool]
7
8 public function getType()
9 {
10 return "Enum";
11 }
12
13
14 // default
15
16 public function reset()
17 {
18 parent::reset();
19
20 $this->options = array();
21 $this->setNumeric(true);
22 }
23
24
25 // properties
26
27 public function isNumeric()
28 {
29 return $this->numeric;
30 }
31
32 public function setNumeric($a_value)
33 {
34 $this->numeric = $a_value;
35 }
36
37 public function getOptions()
38 {
39 return $this->options;
40 }
41
42 public function setOptions(array $a_values)
43 {
44 if ($this->isNumeric()) {
45 foreach (array_keys($a_values) as $key) {
46 if (!is_numeric($key)) {
47 throw new Exception("ilADTEnum was expecting numeric option keys");
48 }
49 }
50 }
51
52 $this->options = $a_values;
53 }
54
55
56 // comparison
57
58 public function isComparableTo(ilADT $a_adt)
59 {
60 // has to be enum-based
61 return ($a_adt instanceof ilADTEnum);
62 }
63
64
65 // ADT instance
66
67 public function getADTInstance()
68 {
69 if ($this->isNumeric()) {
70 $class = "ilADTEnumNumeric";
71 } else {
72 $class = "ilADTEnumText";
73 }
74 include_once "Services/ADT/classes/Types/Enum/class.ilADTEnum.php";
75 include_once "Services/ADT/classes/Types/Enum/class." . $class . ".php";
76 return new $class($this);
77 }
78}
An exception for terminatinating execution or to throw for unit testing.
ADT definition base class.
isComparableTo(ilADT $a_adt)
Check if given ADT is comparable to self.
reset()
Init property defaults.
getType()
Get type (from class/instance)
ADT base class.
Definition: class.ilADT.php:12