ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilADTEnum.php
Go to the documentation of this file.
1<?php
2
3abstract class ilADTEnum extends ilADT
4{
5 protected $value; // [string]
6
7
8 // definition
9
10 protected function isValidDefinition(ilADTDefinition $a_def)
11 {
12 return ($a_def instanceof ilADTEnumDefinition);
13 }
14
15 public function reset()
16 {
17 parent::reset();
18
19 $this->value = null;
20 }
21
22
23 // properties
24
25 abstract protected function handleSelectionValue($a_value);
26
27 public function setSelection($a_value = null)
28 {
29 if($a_value !== null)
30 {
31 $a_value = $this->handleSelectionValue($a_value);
32 if(!$this->isValidOption($a_value))
33 {
34 $a_value = null;
35 }
36 }
37 $this->value = $a_value;
38 }
39
40 public function getSelection()
41 {
42 return $this->value;
43 }
44
45 public function isValidOption($a_value)
46 {
47 $a_value = $this->handleSelectionValue($a_value);
48 return array_key_exists($a_value, $this->getDefinition()->getOptions());
49 }
50
51
52 // comparison
53
54 public function equals(ilADT $a_adt)
55 {
56 if($this->getDefinition()->isComparableTo($a_adt))
57 {
58 return ($this->getSelection() === $a_adt->getSelection());
59 }
60 }
61
62 public function isLarger(ilADT $a_adt)
63 {
64 // return null?
65 }
66
67 public function isSmaller(ilADT $a_adt)
68 {
69 // return null?
70 }
71
72
73 // null
74
75 public function isNull()
76 {
77 return ($this->getSelection() === null);
78 }
79
80
81 // check
82
83 public function getCheckSum()
84 {
85 if(!$this->isNull())
86 {
87 return (string)$this->getSelection();
88 }
89 }
90}
91
92?>
ADT definition base class.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.
isValidOption($a_value)
isValidDefinition(ilADTDefinition $a_def)
Check if definition is valid for ADT.
isNull()
Is currently null.
handleSelectionValue($a_value)
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
reset()
Init property defaults.
getCheckSum()
Get unique checksum.
setSelection($a_value=null)
equals(ilADT $a_adt)
Check if given ADT equals self.
ADT base class.
Definition: class.ilADT.php:12
getDefinition()
Get definition.
Definition: class.ilADT.php:99