Backup #761

ID761
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Infrastructure/Config/CredentialService.php
Version2
Typ modified
Größe1.5 KB
Hash6cfe132124b7d39367b92ec3e2c1ce8bb842597b96d65f3f9361e9cfab9a1910
Datum2025-12-23 08:02:20
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

namespace Infrastructure\Config;

use RuntimeException;

/**
 * Centralized credential management.
 *
 * Reads credentials from environment variables (.env file).
 */
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;
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1364 4 modified 1.8 KB 2025-12-25 16:55
1360 3 modified 1.5 KB 2025-12-25 16:55
761 2 modified 1.5 KB 2025-12-23 08:02
124 1 modified 2.8 KB 2025-12-20 19:30

← Zurück zur Übersicht