ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ScalarValue.php
Go to the documentation of this file.
1<?php
2
4
8
10{
11
15 protected $value;
16
17
21 public function __construct()
22 {
23 }
24
25
33 public function serialize()
34 {
35 return serialize($this->value);
36 }
37
38
51 public function unserialize($serialized)
52 {
53 $this->value = unserialize($serialized);
54 }
55
56
62 public function getHash()
63 {
64 return md5($this->serialize());
65 }
66
67
73 public function equals(Value $other)
74 {
75 if (!$other instanceof ScalarValue) {
76 return false;
77 }
78
79 return $this->value == $other->getValue();
80 }
81
82
86 public function getValue()
87 {
88 return $this->value;
89 }
90
91
98 public function setValue($value)
99 {
100 if (!is_scalar($value)) {
101 throw new InvalidArgumentException("The value given must be a scalar! See php-documentation is_scalar().");
102 }
103
104 $this->value = $value;
105 }
106}
An exception for terminatinating execution or to throw for unit testing.