ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilForumNotificationCache.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28  private array $storage = [];
29 
34  public function fetch(string $id)
35  {
36  if (false === $this->exists($id)) {
37  throw new InvalidArgumentException('Storage id doesn\'t exist');
38  }
39 
40  return $this->storage[$id];
41  }
42 
48  public function store(string $key, $data): void
49  {
50  $this->storage[$key] = $data;
51  }
52 
53  public function exists(string $id): bool
54  {
55  return array_key_exists($id, $this->storage);
56  }
57 
62  public function createKeyByValues(array $values): string
63  {
64  foreach ($values as &$value) {
65  if ($value !== null && !is_scalar($value)) {
66  throw new InvalidArgumentException(sprintf(
67  "Value %s is not scalar and can't be used to build a key",
68  print_r($value, true)
69  ));
70  }
71 
72  $value = (string) $value;
73  }
74 
75  return md5(implode('|', $values));
76  }
77 }
Class ilForumNotificationCache.
string $key
Consumer key/client ID value.
Definition: System.php:193
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23