ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
TupleValue.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 class TupleValue extends AbstractValue
9 {
10 
14  protected $values = [];
18  protected $type = "";
19 
20 
26  public function __construct()
27  {
28  }
29 
30 
38  public function serialize()
39  {
40  return serialize($this->values);
41  }
42 
43 
56  public function unserialize($serialized)
57  {
58  $this->values = $this->unserialize($serialized);
59  $this->type = $this->calculateLowestCommonType($this->values);
60  }
61 
62 
68  public function getHash()
69  {
70  $hashes = '';
71  foreach ($this->getValues() as $value) {
72  $hashes .= $value->getHash();
73  }
74 
75  return md5($hashes);
76  }
77 
78 
84  public function equals(Value $other)
85  {
86  if (!$other instanceof ListValue) {
87  return false;
88  }
89 
90  if ($this->getType() != $other->getType()) {
91  return false;
92  }
93 
94  $values = $this->getValues();
95  $otherValues = $other->getList();
96 
97  if (count($values) != count($otherValues)) {
98  return false;
99  }
100 
101  for ($i = 0; $i < count($values); $i++) {
102  if (!$values[$i]->equals($otherValues[$i])) {
103  ;
104  }
105  }
106 
107  return true;
108  }
109 
110 
114  public function getValues()
115  {
116  return $this->values;
117  }
118 
119 
124  public function getType()
125  {
126  return $this->type;
127  }
128 
129 
135  private function constructType($list)
136  {
137  return "(" + implode(",", $list->getType()) + ")";
138  }
139 
140 
145  public function setValue($values)
146  {
147  $wrapperFactory = \PrimitiveValueWrapperFactory::getInstance();
148  foreach ($values as $value) {
149  $this->$values[] = $wrapperFactory->wrapValue($value);
150  }
151 
152  $this->type = $this->constructType($this->values);
153  }
154 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$i
Definition: disco.tpl.php:19