ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
EntryLockingStringMap.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
21 final class EntryLockingStringMap implements StringMap
22 {
27  private $map;
28 
29 
33  public function __construct()
34  {
35  $this->map = new \ArrayObject();
36  }
37 
38 
51  public function get($key)
52  {
53  $this->stringTypeCheck($key, 'key');
54 
55  if ($this->map->offsetExists($key)) {
56  return $this->map->offsetGet($key);
57  }
58 
59  throw new NoSuchElementException("No meta data associated with key \"$key\".");
60  }
61 
62 
70  public function toArray()
71  {
72  return $this->map->getArrayCopy();
73  }
74 
75 
87  public function has($key)
88  {
89  $this->stringTypeCheck($key, 'key');
90 
91  return $this->map->offsetExists($key);
92  }
93 
94 
110  public function put($key, $value)
111  {
112  $this->stringTypeCheck($key, 'key');
113  $this->stringTypeCheck($value, 'value');
114 
115  if ($this->map->offsetExists($key)) {
116  throw new ElementAlreadyExistsException("Element $key can not be overwritten.");
117  }
118 
119  $this->map->offsetSet($key, $value);
120  }
121 }
toArray()
Returns all currently known entries.
__construct()
EntryLockingStringMap constructor.
put($key, $value)
Puts a new key value pair into the string array.
has($key)
Probe if the key is known and associated with a value.
$key
Definition: croninfo.php:18