$scanResult Scan result metrics and violations array * @param string $targetUrl Target URL or file name audited * @return string Raw PDF binary data */ public static function generatePdf(array $scanResult, string $targetUrl): string { if (!class_exists(Dompdf::class)) { throw new \RuntimeException('To generate PDF certificates, please install dompdf via: composer require dompdf/dompdf'); } /** @var int $score */ $score = is_numeric($scanResult['score'] ?? null) ? intval($scanResult['score']) : 0; /** @var array> $violations */ $violations = is_array($scanResult['violations'] ?? null) ? $scanResult['violations'] : []; $violationsCount = count($violations); $dateStr = date('d.m.Y H:i'); $scoreColor = $score >= 80 ? '#10b981' : ($score >= 50 ? '#f59e0b' : '#ef4444'); $statusText = $score >= 80 ? 'WCAG 2.1 AA Uyumlu (Pass)' : ($score >= 50 ? 'İyileştirme Gerekli (Warning)' : 'Kritik İhlaller (Fail)'); $violationsHtml = ''; $slicedViolations = array_slice($violations, 0, 25); foreach ($slicedViolations as $idx => $v) { /** @var array $v */ $num = $idx + 1; $ruleIdVal = is_string($v['ruleId'] ?? null) ? $v['ruleId'] : ''; $descVal = is_string($v['description'] ?? null) ? $v['description'] : ''; $snippetVal = is_string($v['htmlSnippet'] ?? null) ? $v['htmlSnippet'] : ''; $suggestionVal = is_string($v['suggestion'] ?? null) ? $v['suggestion'] : ''; $ruleId = htmlspecialchars($ruleIdVal); $desc = htmlspecialchars($descVal); $snippet = htmlspecialchars($snippetVal); $suggestion = htmlspecialchars($suggestionVal); $violationsHtml .= "
#{$num} [{$ruleId}] {$desc}
{$snippet}
Öneri: {$suggestion}
"; } $html = " WCAG 2.1 Erişilebilirlik Sertifikası ve Raporu
♿ YakNet Accessibility Console
WCAG 2.1 AA Erişilebilirlik Uyumluluk Raporu
Erişilebilirlik Sağlık Skoru
{$score} / 100
{$statusText}
Hedef URL / Dizin: " . htmlspecialchars($targetUrl) . "
Tarama Tarihi: {$dateStr}
Tespit Edilen İhlal Sayısı: {$violationsCount} Hata
Raporu Üreten Motor: YakNet AI & Accessibility Engine v3.1

📋 Erişilebilirlik İhlalleri ve Çözüm Detayları

{$violationsHtml} "; $options = new Options(); $options->set('isHtml5ParserEnabled', true); $options->set('isRemoteEnabled', true); $dompdf = new Dompdf($options); $dompdf->loadHtml($html); $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); return strval($dompdf->output()); } }