InvoiceRuntimeConfig.php
Pfad: src/Infrastructure/Rechnung/InvoiceRuntimeConfig.php
Ext: php
Größe: 1156 Bytes
Geändert: 2026-07-16 17:37:59+02
<?php
declare(strict_types=1);
namespace Demo\Infrastructure\Rechnung;
final class InvoiceRuntimeConfig
{
public function __construct(
public readonly string $runId,
public readonly string $statePath,
public readonly string $originalsPath,
public readonly string $logPath,
public readonly int $maxRetries,
public readonly float $amountTolerance,
) {
}
public static function fromEnvironment(string $root): self
{
return new self(
JsonRuntimeConfig::environment('RECHNUNGEN_RUN_ID') ?? ('run_' . date('Ymd_His')),
JsonRuntimeConfig::environment('RECHNUNGEN_STATE_PATH') ?? $root . '/rechnungen/rechnungen.json',
JsonRuntimeConfig::environment('RECHNUNGEN_ORIGINAL_BASE_PATH') ?? $root . '/rechnungen/originale',
JsonRuntimeConfig::environment('RECHNUNGEN_LOG_PATH') ?? $root . '/rechnungen/prozess-rechnung.log',
max(0, (int) (JsonRuntimeConfig::environment('RECHNUNGEN_MAX_RETRIES') ?? '3')),
max(0.0, (float) (JsonRuntimeConfig::environment('RECHNUNGEN_AMOUNT_TOLERANCE') ?? '0.01')),
);
}
}