<?php
declare(strict_types=1);
namespace Infrastructure\Config;
// @responsibility: Zentrales Credential-Management aus Environment-Variablen
use RuntimeException;
final class CredentialService
{
/**
* Gets the MariaDB root password.
*/
public static function getMariaDbPassword(): string
{
return self::getRequired('MARIADB_ROOT_PASSWORD');
}
/**
* Gets the Anthropic API key.
*/
public static function getAnthropicApiKey(): string
{
return self::getRequired('ANTHROPIC_API_KEY');
}
/**
* Gets the Ollama host URL.
*/
public static function getOllamaHost(): string
{
return self::get('OLLAMA_HOST', 'http://localhost:11434');
}
/**
* Gets the Qdrant host URL.
*/
public static function getQdrantHost(): string
{
return self::get('QDRANT_HOST', 'http://localhost:6333');
}
/**
* Gets an environment variable with a default value.
*/
public static function get(string $key, string $default = ''): string
{
return $_ENV[$key] ?? $_SERVER[$key] ?? getenv($key) ?: $default;
}
/**
* Gets a required environment variable.
*
* @throws RuntimeException If the variable is not set
*/
public static function getRequired(string $key): string
{
$value = self::get($key);
if ($value === '') {
throw new RuntimeException("Required environment variable not set: {$key}");
}
return $value;
}
}