ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ILIAS\FileUpload\Collection\EntryLockingStringMap Class Reference

Class EntryLockingStringMap. More...

+ Inheritance diagram for ILIAS\FileUpload\Collection\EntryLockingStringMap:
+ Collaboration diagram for ILIAS\FileUpload\Collection\EntryLockingStringMap:

Public Member Functions

 __construct ()
 EntryLockingStringMap constructor. More...
 
 get ($key)
 Returns the value of the given key. More...
 
 toArray ()
 Returns all currently known entries. More...
 
 has ($key)
 Probe if the key is known and associated with a value. More...
 
 put ($key, $value)
 Puts a new key value pair into the string array. More...
 

Private Attributes

 $map
 

Detailed Description

Class EntryLockingStringMap.

Implementation of the StringMap which locks the entry after it got created. Therefore it is not possible to overwrite an existing key.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Since
5.3
Version
1.0

Definition at line 21 of file EntryLockingStringMap.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileUpload\Collection\EntryLockingStringMap::__construct ( )

EntryLockingStringMap constructor.

Definition at line 33 of file EntryLockingStringMap.php.

34  {
35  $this->map = new \ArrayObject();
36  }

Member Function Documentation

◆ get()

ILIAS\FileUpload\Collection\EntryLockingStringMap::get (   $key)

Returns the value of the given key.

Parameters
string$keyThe key which should be used to search the corresponding value.
Returns
string
Exceptions
NoSuchElementExceptionThrown if the entry is not found with the given key.

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 51 of file EntryLockingStringMap.php.

References $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  }
$key
Definition: croninfo.php:18

◆ has()

ILIAS\FileUpload\Collection\EntryLockingStringMap::has (   $key)

Probe if the key is known and associated with a value.

Parameters
string$keyThe key which should be checked.
Returns
bool
Exceptions

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 87 of file EntryLockingStringMap.php.

References $key.

88  {
89  $this->stringTypeCheck($key, 'key');
90 
91  return $this->map->offsetExists($key);
92  }
$key
Definition: croninfo.php:18

◆ put()

ILIAS\FileUpload\Collection\EntryLockingStringMap::put (   $key,
  $value 
)

Puts a new key value pair into the string array.

The put operation can not overwrite an existing pair.

Parameters
string$keyThe key which should be put into the map.
string$valueThe value which should be associated with the given key.
Returns
void
Exceptions
ElementAlreadyExistsExceptionThrown if the key already exists in the map.

Implements ILIAS\FileUpload\Collection\StringMap.

Definition at line 110 of file EntryLockingStringMap.php.

References $key.

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  }
$key
Definition: croninfo.php:18

◆ toArray()

ILIAS\FileUpload\Collection\EntryLockingStringMap::toArray ( )

Returns all currently known entries.

Returns
string[]
Since
5.3

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 70 of file EntryLockingStringMap.php.

71  {
72  return $this->map->getArrayCopy();
73  }

Field Documentation

◆ $map

ArrayObject ILIAS\FileUpload\Collection\EntryLockingStringMap::$map
private

Definition at line 27 of file EntryLockingStringMap.php.


The documentation for this class was generated from the following file: