blob: 2c2a60694ffe33dfc068785d0a7efc1e889b9b42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?php
/**
* Test stub for legacy global Property class.
*/
class Property
{
public static array $values = [];
public static function reset(): void
{
self::$values = [];
}
public static function get(string $key, $default = null)
{
return array_key_exists($key, self::$values) ? self::$values[$key] : $default;
}
public static function set(string $key, $value): void
{
self::$values[$key] = $value;
}
// List emulation helpers used by RebootControl
public static function addToList(string $key, string $value, int $max = 50): void
{
$list = self::$values[$key] ?? [];
if (!is_array($list)) $list = [];
$list[] = $value;
// Trim to max items (keep latest entries)
if ($max > 0 && count($list) > $max) {
$list = array_slice($list, -$max);
}
self::$values[$key] = $list;
}
public static function getList(string $key): array
{
$value = self::$values[$key] ?? [];
return is_array($value) ? $value : [];
}
public static function removeFromListByKey(string $key, $subkey): void
{
if (!isset(self::$values[$key]) || !is_array(self::$values[$key])) return;
unset(self::$values[$key][$subkey]);
// reindex to keep it simple
self::$values[$key] = array_values(self::$values[$key]);
}
}
|