[], 'lastSeen' => [] ]; } public static function fromJson(string $json): array { $data = json_decode($json, true); if (!is_array($data)) { return self::empty(); } return array_replace(self::empty(), $data); } public static function toJson(array $state): string { return json_encode(array_replace(self::empty(), $state)); } public static function touch(array $state, string $chargePointId, string $remote = ''): array { $state = array_replace(self::empty(), $state); $state['connections'][$chargePointId] = [ 'chargePointId' => $chargePointId, 'remote' => $remote, 'timestamp' => time() ]; $state['lastSeen'][$chargePointId] = time(); return $state; } } ?>