first(); if (!$setting) { static::$cache[$key] = $default; return $default; } $value = $setting->value; // 根據 type 進行類別轉換 $resolved = match ($setting->type) { 'integer', 'number' => (int) $value, 'boolean', 'bool' => filter_var($value, FILTER_VALIDATE_BOOLEAN), 'json', 'array' => json_decode($value, true), default => $value, }; static::$cache[$key] = $resolved; return $resolved; } /** * 清除記憶體快取(儲存設定後應呼叫) */ public static function clearCache(): void { static::$cache = []; } }