ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SelectSetting.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use 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}
typed(string $name, Closure $convert_with)
__construct(private readonly KeyValueStore $store, private readonly Marshal $marshal)