ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 put ($key, $value)
 Puts a new key value pair into the string array. More...
 
 get ($key)
 Returns the value of the key from the additional metadata. More...
 
 toArray ()
 Returns all currently known entries. More...
 
 has ($key)
 Probe if the key is known and associated with a value. 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

@Internal

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.

InvalidArgumentException Thrown if the key type is not of the type string.

Since
5.3

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 51 of file EntryLockingStringMap.php.

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 }

◆ 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

InvalidArgumentException Thrown if the key type is not of the type string.

Since
5.3

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 87 of file EntryLockingStringMap.php.

88 {
89 $this->stringTypeCheck($key, 'key');
90
91 return $this->map->offsetExists($key);
92 }

◆ 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.

InvalidArgumentException Thrown if the key or value is not of the type string.

Since
5.3

Implements ILIAS\FileUpload\Collection\StringMap.

Definition at line 110 of file EntryLockingStringMap.php.

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 }

◆ 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: