CredentialService.php
- Pfad:
src/Infrastructure/Config/CredentialService.php - Namespace: Infrastructure\Config
- Zeilen: 93 | Größe: 2,091 Bytes
- Geändert: 2025-12-25 16:55:39 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 1
- use RuntimeException
Klassen 1
-
CredentialServiceclass Zeile 11
Funktionen 9
-
getMariaDbHost()public Zeile 16 -
getMariaDbUser()public Zeile 24 -
getMariaDbPassword()public Zeile 32 -
getAnthropicApiKey()public Zeile 40 -
getOllamaHost()public Zeile 48 -
getQdrantHost()public Zeile 56 -
getCredentialsFilePath()public Zeile 64 -
get()public Zeile 72 -
getRequired()public Zeile 82
Verwendet von 8
- AIConfig.php use
- ClaudeService.php use
- ContentSearchService.php use
- ExecuteAITaskUseCase.php use
- OllamaClient.php use
- OllamaService.php use
- QdrantClient.php use
- QdrantService.php use
Versionen 4
-
v4
2025-12-25 16:55 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v3
2025-12-25 16:55 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v2
2025-12-23 08:02 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Edit-Operation -
v1
2025-12-20 19:30 | claude-code-hook | modified
Claude Code Pre-Hook Backup vor Write-Operation
Code
<?php
declare(strict_types=1);
namespace Infrastructure\Config;
// @responsibility: Zentrales Credential-Management aus Environment-Variablen
use RuntimeException;
final class CredentialService
{
/**
* Gets the MariaDB host.
*/
public static function getMariaDbHost(): string
{
return self::get('MARIADB_HOST', 'localhost');
}
/**
* Gets the MariaDB user.
*/
public static function getMariaDbUser(): string
{
return self::get('MARIADB_USER', 'root');
}
/**
* 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 the credentials file path.
*/
public static function getCredentialsFilePath(): string
{
return self::get('CREDENTIALS_FILE_PATH', '/var/www/docs/credentials/credentials.md');
}
/**
* 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;
}
}