ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
EntryLockingStringMap.php
Go to the documentation of this file.
1<?php
2
20
23use ILIAS\FileUpload\ScalarTypeCheckAware;
24
37final class EntryLockingStringMap implements StringMap
38{
39 use ScalarTypeCheckAware;
40 private \ArrayObject $map;
41
42
46 public function __construct()
47 {
48 $this->map = new \ArrayObject();
49 }
50
51
61 public function get(string $key): string
62 {
63 $this->stringTypeCheck($key, 'key');
64
65 if ($this->map->offsetExists($key)) {
66 return $this->map->offsetGet($key);
67 }
68
69 throw new NoSuchElementException("No meta data associated with key \"$key\".");
70 }
71
72
80 public function toArray(): array
81 {
82 return $this->map->getArrayCopy();
83 }
84
85
94 public function has(string $key): bool
95 {
96 $this->stringTypeCheck($key, 'key');
97
98 return $this->map->offsetExists($key);
99 }
100
101
114 public function put(string $key, string $value): void
115 {
116 $this->stringTypeCheck($key, 'key');
117 $this->stringTypeCheck($value, 'value');
118
119 if ($this->map->offsetExists($key)) {
120 throw new ElementAlreadyExistsException("Element $key can not be overwritten.");
121 }
122
123 $this->map->offsetSet($key, $value);
124 }
125}
has(string $key)
Probe if the key is known and associated with a value.
put(string $key, string $value)
Puts a new key value pair into the string array.
toArray()
Returns all currently known entries.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...