$content */ public static function encode(array $content): string { $encryption = strtoupper(trim((string) ($content['encryption'] ?? 'WPA'))); $auth = $encryption === 'NOPASS' ? 'nopass' : $encryption; if (! in_array($auth, ['WPA', 'WEP', 'nopass'], true)) { $auth = 'WPA'; } $ssid = self::escape(trim((string) ($content['ssid'] ?? ''))); $payload = 'WIFI:T:' . $auth . ';S:' . $ssid; if ($auth !== 'nopass') { $password = trim((string) ($content['password'] ?? '')); if ($password !== '') { $payload .= ';P:' . self::escape($password); } } if (filter_var($content['hidden'] ?? false, FILTER_VALIDATE_BOOL)) { $payload .= ';H:true'; } return $payload . ';;'; } private static function escape(string $value): string { return str_replace( ['\\', ';', ',', '"', ':'], ['\\\\', '\\;', '\\,', '\\"', '\\:'], $value ); } }