ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ 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
{
33
private
$values
= [];
34
38
public
function
getData
() : array
39
{
40
return
$this->values
;
41
}
42
47
public
function
add
(
string
$key, $value) : void
48
{
49
if
($this->
exists
($key)) {
50
throw
new
LogicException
(
"Key $key already exists."
);
51
}
52
$this->values[$key] = $value;
53
}
54
59
public
function
get
(
string
$key)
60
{
61
return
$this->values[$key];
62
}
63
69
public
function
is
(
string
$key, $expected_value) : bool
70
{
71
return
($this->
exists
($key) && $this->
get
($key) === $expected_value);
72
}
73
78
public
function
exists
(
string
$key) : bool
79
{
80
return
isset($this->values[$key]);
81
}
82
87
public
function
replace
(
string
$key, $value) : void
88
{
89
if
(!$this->
exists
($key)) {
90
throw
new
LogicException
(
"Key $key does not exists."
);
91
}
92
$this->values[$key] = $value;
93
}
94
}
LogicException
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\add
add(string $key, $value)
Definition:
Collection.php:47
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\$values
$values
Definition:
Collection.php:33
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\is
is(string $key, $expected_value)
Definition:
Collection.php:69
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\exists
exists(string $key)
Definition:
Collection.php:78
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection
Class Collection.
Definition:
Collection.php:28
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\replace
replace(string $key, $value)
Definition:
Collection.php:87
ILIAS\GlobalScreen\ScreenContext\AdditionalData
Definition:
Collection.php:20
ILIAS\GlobalScreen\ScreenContext\AdditionalData\Collection\getData
getData()
Definition:
Collection.php:38
src
GlobalScreen
ScreenContext
AdditionalData
Collection.php
Generated on Mon Sep 1 2025 21:01:46 for ILIAS by
1.8.13 (using
Doxyfile
)