ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SetGetProbe.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
25class SetGetProbe implements \ArrayAccess
26{
27 public function __construct(
28 protected $set_probe,
29 protected $get_probe
30 ) {
31 if (!is_callable($set_probe)) {
32 throw new \InvalidArgumentException(
33 "Expected \$probe to be callable."
34 );
35 }
36
37 if (!is_callable($get_probe)) {
38 throw new \InvalidArgumentException(
39 "Expected \$probe to be callable."
40 );
41 }
42 }
43
44 public function offsetExists($offset): bool
45 {
46 return false;
47 }
48
49 public function offsetGet($offset): mixed
50 {
51 $probe = $this->get_probe;
52 return $probe($offset);
53 }
54
55 public function offsetSet($offset, $value): void
56 {
57 $probe = $this->set_probe;
58 $probe($offset, $value);
59 }
60
61 public function offsetUnset($offset): void
62 {
63 }
64}
__construct(protected $set_probe, protected $get_probe)
Definition: SetGetProbe.php:27