ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SelectSetting.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use Closure;
24 
26 {
27  public function __construct(
28  private readonly KeyValueStore $store,
29  private readonly Marshal $marshal
30  ) {
31  }
32 
36  public function typed(string $name, Closure $convert_with): Setting
37  {
38  $convert = $convert_with($this->marshal);
39 
40  return new Setting(
41  fn() => $convert->fromString()->transform($this->store->value($name)),
42  fn($value) => $this->store->update($name, $convert->toString()->transform($value))
43  );
44  }
45 }
__construct(private readonly KeyValueStore $store, private readonly Marshal $marshal)
typed(string $name, Closure $convert_with)