ILIAS
trunk Revision v11.0_alpha-2638-g80c1d007f79
◀ ilDoc Overview
Collection.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
namespace
ILIAS\GlobalScreen\ScreenContext\AdditionalData
;
21
22
use
LogicException
;
23
28
class
Collection
29
{
30
private
array
$values
= [];
31
35
public
function
getData
(): array
36
{
37
return
$this->values
;
38
}
39
44
public
function
add
(
string
$key, $value): void
45
{
46
if
($this->
exists
($key)) {
47
throw
new
LogicException
(
"Key $key already exists."
);
48
}
49
$this->values[$key] = $value;
50
}
51
56
public
function
get
(
string
$key)
57
{
58
return
$this->values[$key];
59
}
60
66
public
function
is
(
string
$key, $expected_value): bool
67
{
68
return
($this->
exists
($key) && $this->
get
($key) === $expected_value);
69
}
70
75
public
function
exists
(
string
$key): bool
76
{
77
return
isset($this->values[$key]);
78
}
79
84
public
function
replace
(
string
$key, $value): void
85
{
86
if
(!$this->
exists
($key)) {
87
throw
new
LogicException
(
"Key $key does not exists."
);
88
}
89
$this->values[$key] = $value;
90
}
91
}
LogicException
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\add
add(string $key, $value)
Definition:
Collection.php:44
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\is
is(string $key, $expected_value)
Definition:
Collection.php:66
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\exists
exists(string $key)
Definition:
Collection.php:75
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection
Class Collection.
Definition:
Collection.php:28
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\$values
array $values
Definition:
Collection.php:30
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\replace
replace(string $key, $value)
Definition:
Collection.php:84
ILIAS\GlobalScreen\ScreenContext\AdditionalData
Definition:
Collection.php:20
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\getData
getData()
Definition:
Collection.php:35
components
ILIAS
GlobalScreen
src
ScreenContext
AdditionalData
Collection.php
Generated on Sun Aug 31 2025 23:02:05 for ILIAS by
1.8.13 (using
Doxyfile
)