Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: v3.2.0 - Enterprise Edition with Live Web Dashboard, PDF/Excel Exporters, Framework Stubs & 110 WCAG Rules
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace YakNet\AccessibilityConsole\Audit;
|
||||
|
||||
use YakNet\AccessibilityConsole\Core\Scanner;
|
||||
|
||||
class SiteCrawler
|
||||
{
|
||||
private Scanner $scanner;
|
||||
|
||||
public function __construct(?Scanner $scanner = null)
|
||||
{
|
||||
$this->scanner = $scanner ?? new Scanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Crawl and scan multiple pages of a website up to a maximum page limit.
|
||||
*
|
||||
* @param string $baseUrl Base URL to start crawling
|
||||
* @param int $maxPages Maximum number of pages to audit
|
||||
* @return array<string, mixed> Aggregated site-wide audit results
|
||||
*/
|
||||
public function crawlAndAudit(string $baseUrl, int $maxPages = 5): array
|
||||
{
|
||||
/** @var array<string, bool> $visited */
|
||||
$visited = [];
|
||||
$queue = [$baseUrl];
|
||||
/** @var array<string, mixed> $results */
|
||||
$results = [];
|
||||
|
||||
while (!empty($queue) && count($visited) < $maxPages) {
|
||||
$url = array_shift($queue);
|
||||
if (empty($url) || isset($visited[$url])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$visited[$url] = true;
|
||||
try {
|
||||
$html = @file_get_contents($url);
|
||||
$violations = $html !== false ? $this->scanner->scan($html) : [];
|
||||
$score = max(0, 100 - count($violations) * 3);
|
||||
|
||||
$results[$url] = [
|
||||
'score' => $score,
|
||||
'violations_count' => count($violations),
|
||||
'violations' => $violations,
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
$results[$url] = ['error' => $e->getMessage(), 'score' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
$scores = [];
|
||||
$totalViolations = 0;
|
||||
foreach ($results as $res) {
|
||||
if (is_array($res)) {
|
||||
if (isset($res['score']) && is_numeric($res['score'])) {
|
||||
$scores[] = intval($res['score']);
|
||||
}
|
||||
if (isset($res['violations_count']) && is_numeric($res['violations_count'])) {
|
||||
$totalViolations += intval($res['violations_count']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$avgScore = count($scores) > 0 ? (int)round(array_sum($scores) / count($scores)) : 0;
|
||||
|
||||
return [
|
||||
'base_url' => $baseUrl,
|
||||
'pages_audited' => count($visited),
|
||||
'average_score' => $avgScore,
|
||||
'total_violations' => $totalViolations,
|
||||
'page_results' => $results,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user