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