<?php
declare(strict_types=1);

namespace App\Core\Http;

final class SslCertificateResolver
{
    public static function resolve(): ?string
    {
        $envPath = (string) ($_ENV['CURL_CA_BUNDLE_PATH'] ?? '');
        if ($envPath !== '' && is_file($envPath)) {
            return $envPath;
        }
        $iniPath = (string) ini_get('curl.cainfo');
        if ($iniPath !== '' && is_file($iniPath)) {
            return $iniPath;
        }
        $candidates = [
            'C:/xampp/apache/bin/curl-ca-bundle.crt',
            'C:/xampp/php/extras/ssl/cacert.pem',
            '/etc/ssl/certs/ca-certificates.crt',
        ];
        foreach ($candidates as $path) {
            if (is_file($path)) {
                return $path;
            }
        }
        return null;
    }
}
