ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ScalarValue.php
Go to the documentation of this file.
1 <?php
2 
20 
24 
26 {
30  protected $value;
31 
38  public function serialize()
39  {
40  return serialize($this->value);
41  }
42 
52  public function unserialize($serialized)
53  {
54  $this->value = unserialize($serialized);
55  }
56 
62  public function getHash(): string
63  {
64  return md5($this->serialize());
65  }
66 
67  public function equals(Value $other): bool
68  {
69  if (!$other instanceof ScalarValue) {
70  return false;
71  }
72 
73  return $this->value == $other->getValue();
74  }
75 
79  public function getValue()
80  {
81  return $this->value;
82  }
83 
88  public function setValue($value): void
89  {
90  if (!is_scalar($value)) {
91  throw new InvalidArgumentException("The value given must be a scalar! See php-documentation is_scalar().");
92  }
93 
94  $this->value = $value;
95  }
96 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
unserialize($serialized)
Constructs the object http://php.net/manual/en/serializable.unserialize.php.
Definition: ScalarValue.php:52
serialize()
String representation of object http://php.net/manual/en/serializable.serialize.php.
Definition: ScalarValue.php:38