U-D/U-E/O5: Prozess-Tester im eigenen Prozess (standardmäßig gesperrt, 15 Negativtests, statischer Wächter), Szenarien und Bericht, Kanalereignisse (API-Eingang ohne Umbau von iCal/Mail), Abschluss nach finanzieller Klärung, Löschfrist 30 Tage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c255783cec
commit
0689c0a591
68 files changed
+3350
-35
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester;
|
||||
|
||||
/**
|
||||
* The record of a tester run: every simulated effect and every violation, appended line by line to a file in the
|
||||
* run's directory – it survives exceptions, and what an action swallowed is still there.
|
||||
*/
|
||||
final class EffectLedger
|
||||
{
|
||||
private static ?string $path = null;
|
||||
|
||||
public static function open(string $path): void
|
||||
{
|
||||
self::$path = $path;
|
||||
}
|
||||
|
||||
public static function isOpen(): bool
|
||||
{
|
||||
return self::$path !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function record(string $type, array $data = []): void
|
||||
{
|
||||
if (self::$path === null) {
|
||||
return;
|
||||
}
|
||||
file_put_contents(self::$path, json_encode(['type' => $type, ...$data], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)."\n", FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function entries(): array
|
||||
{
|
||||
if (self::$path === null || ! is_file(self::$path)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_map(fn (string $line): array => (array) json_decode($line, true), array_filter(explode("\n", (string) file_get_contents(self::$path)))));
|
||||
}
|
||||
|
||||
public static function violations(): array
|
||||
{
|
||||
return array_values(array_filter(self::entries(), fn (array $entry): bool => ($entry['type'] ?? null) === 'violation'));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user