Total Complexity | 6 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | class EventReferenceParameter |
||
21 | { |
||
22 | protected mixed $parameter; |
||
23 | |||
24 | public function __construct( |
||
25 | mixed &$parameter, |
||
26 | protected bool $allowTypeChange = false |
||
27 | ) { |
||
28 | $this->parameter = &$parameter; |
||
29 | } |
||
30 | |||
31 | public function getParameterValue(): mixed |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @throws PhpfastcacheInvalidTypeException |
||
38 | */ |
||
39 | public function setParameterValue(mixed $newValue): void |
||
40 | { |
||
41 | if (!$this->allowTypeChange) { |
||
42 | $currentType = \gettype($this->parameter); |
||
43 | $newType = \gettype($newValue); |
||
44 | if ($newType !== $currentType) { |
||
45 | throw new PhpfastcacheInvalidTypeException( |
||
46 | \sprintf('You tried to change the variable type from "%s" to "%s" which is not allowed.', $currentType, $newType) |
||
47 | ); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | $this->parameter = $newValue; |
||
52 | } |
||
53 | |||
54 | public function __invoke(): mixed |
||
57 | } |
||
58 | } |
||
59 |