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, ]; } }