Files
Adminator 1e51ef7def Nachtrag: alle bisher untracked Ordner + hängende Änderungen mit-committen
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/
- 12 code-workspace-Files
- STATUS-*.md
- viele M/D/R-Änderungen an bereits getrackten Files
- .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-08 02:27:02 +02:00

82 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
/**
* Console-Output + JSON-Report.
* Farben via ANSI-Codes (in CMD.exe stumm — egal, Text bleibt lesbar).
*/
class Report {
private array $entries = [];
private int $passed = 0;
private int $failed = 0;
private int $warning = 0;
private string $slug;
private string $version;
private bool $color;
public function __construct(string $slug, string $version) {
$this->slug = $slug;
$this->version = $version;
// ANSI nur auf Linux/Mac und auf Windows mit ConEmu/WT
$this->color = stream_isatty(STDOUT) && DIRECTORY_SEPARATOR !== '\\';
}
public function info(string $msg): void {
echo $msg . "\n";
$this->entries[] = ['type' => 'info', 'msg' => $msg];
}
public function ok(string $msg): void {
$pre = $this->color ? "\033[32m✓\033[0m" : "[OK]";
echo "$pre $msg\n";
$this->entries[] = ['type' => 'ok', 'msg' => $msg];
$this->passed++;
}
public function fail(string $msg, array $details = []): void {
$pre = $this->color ? "\033[31m✗\033[0m" : "[FAIL]";
echo "$pre $msg\n";
foreach ($details as $d) echo " $d\n";
$this->entries[] = ['type' => 'fail', 'msg' => $msg, 'details' => $details];
$this->failed++;
}
public function warn(string $msg, array $details = []): void {
$pre = $this->color ? "\033[33m⚠\033[0m" : "[WARN]";
echo "$pre $msg\n";
foreach ($details as $d) echo " $d\n";
$this->entries[] = ['type' => 'warn', 'msg' => $msg, 'details' => $details];
$this->warning++;
}
public function error(string $msg): void {
$pre = $this->color ? "\033[1;31m!!\033[0m" : "[ERROR]";
echo "$pre $msg\n";
}
public function note(string $msg): void {
echo " · $msg\n";
$this->entries[] = ['type' => 'note', 'msg' => $msg];
}
public function summary(): array {
return [
'passed' => $this->passed,
'failed' => $this->failed,
'warning' => $this->warning,
];
}
public function toArray(): array {
return [
'module' => $this->slug,
'version' => $this->version,
'generated_at' => date('c'),
'phase' => 'phase-1-php-only',
'summary' => $this->summary(),
'lieferbereit' => $this->failed === 0,
'entries' => $this->entries,
];
}
}