ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
State.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2018 - Richard Klees <richard.klees@concepts-and-training.de> - Extended GPL, see LICENSE */
3 
4 namespace ILIAS\KioskMode;
5 
9 class State
10 {
11 
15  protected $store;
16 
20  public function withValueFor(string $key, string $value) : State
21  {
22  $clone = clone $this;
23  $clone->store[$key] = $value;
24  return $clone;
25  }
26 
30  public function withoutKey(string $key) : State
31  {
32  $clone = clone $this;
33  unset($clone->store[$key]);
34  return $clone;
35  }
36 
40  public function getValueFor(string $key) : string
41  {
42  return $this->store[$key];
43  }
44 
48  public function serialize() : string
49  {
50  return json_encode($this->store);
51  }
52 }
withValueFor(string $key, string $value)
Set a value for a key of the state.
Definition: State.php:20
getValueFor(string $key)
Get the value for the given key.
Definition: State.php:40
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:9
serialize()
Get the key-value store as string.
Definition: State.php:48
withoutKey(string $key)
Remove the key-value-pair.
Definition: State.php:30
$key
Definition: croninfo.php:18