ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (string $key)
 Returns the value of the given key. More...
 
 toArray ()
 Returns all currently known entries. More...
 
 has (string $key)
 Probe if the key is known and associated with a value. More...
 
 put (string $key, string $value)
 Puts a new key value pair into the string array. More...
 
 put (string $key, string $value)
 Puts a new key value pair into the string array. More...
 
 get (string $key)
 Returns the value of the key from the additional metadata. More...
 
 toArray ()
 Returns all currently known entries. More...
 
 has (string $key)
 Probe if the key is known and associated with a value. More...
 

Private Attributes

ArrayObject $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 37 of file EntryLockingStringMap.php.

Constructor & Destructor Documentation

◆ __construct()

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

EntryLockingStringMap constructor.

Definition at line 46 of file EntryLockingStringMap.php.

47 {
48 $this->map = new \ArrayObject();
49 }

Member Function Documentation

◆ get()

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

Returns the value of the given key.

Parameters
string$keyThe key which should be used to search the corresponding value.
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 61 of file EntryLockingStringMap.php.

61 : 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 }

◆ has()

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

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

Parameters
string$keyThe key which should be checked.
Exceptions

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

Since
5.3

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 94 of file EntryLockingStringMap.php.

94 : bool
95 {
96 $this->stringTypeCheck($key, 'key');
97
98 return $this->map->offsetExists($key);
99 }

◆ put()

ILIAS\FileUpload\Collection\EntryLockingStringMap::put ( string  $key,
string  $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.
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 114 of file EntryLockingStringMap.php.

114 : 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 }

◆ toArray()

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

Returns all currently known entries.

Returns
string[]
Since
5.3

Implements ILIAS\FileUpload\Collection\ImmutableStringMap.

Definition at line 80 of file EntryLockingStringMap.php.

80 : array
81 {
82 return $this->map->getArrayCopy();
83 }

Field Documentation

◆ $map

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

Definition at line 40 of file EntryLockingStringMap.php.


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