From 7755d8385c66ee7dd87e99382f7d265c82ff0403 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Fri, 1 May 2026 14:34:34 +0000 Subject: [PATCH] feat: scaffold RedactorInterface and ProjectZomboidRedactor with toggles --- .../ProjectZomboid/ProjectZomboidRedactor.php | 89 +++++++++++++++++++ src/Util/RedactorInterface.php | 20 +++++ 2 files changed, 109 insertions(+) create mode 100644 src/Util/ProjectZomboid/ProjectZomboidRedactor.php create mode 100644 src/Util/RedactorInterface.php diff --git a/src/Util/ProjectZomboid/ProjectZomboidRedactor.php b/src/Util/ProjectZomboid/ProjectZomboidRedactor.php new file mode 100644 index 0000000..a4e96f6 --- /dev/null +++ b/src/Util/ProjectZomboid/ProjectZomboidRedactor.php @@ -0,0 +1,89 @@ + name -> coordinates is mandatory. + * 3. Coordinates pass — replaces world coordinate triplets with a placeholder + * token. + * + * All regex passes use the /u flag for Unicode safety. + * + * Replacements are not reversible; do not apply to content that must later be + * restored to its original form. + */ +class ProjectZomboidRedactor implements RedactorInterface +{ + private bool $redactSteamIds = true; + private bool $redactPlayerNames = true; + private bool $redactCoordinates = true; + + /** + * Enable or disable the Steam ID redaction pass. + * + * @param bool $on Pass true to enable, false to disable. + * @return static + */ + public function redactSteamIds(bool $on): static + { + $this->redactSteamIds = $on; + return $this; + } + + /** + * Enable or disable the player-name redaction pass. + * + * @param bool $on Pass true to enable, false to disable. + * @return static + */ + public function redactPlayerNames(bool $on): static + { + $this->redactPlayerNames = $on; + return $this; + } + + /** + * Enable or disable the coordinates redaction pass. + * + * @param bool $on Pass true to enable, false to disable. + * @return static + */ + public function redactCoordinates(bool $on): static + { + $this->redactCoordinates = $on; + return $this; + } + + /** + * Redact PII from the given Project Zomboid log content. + * + * Passes are applied in the mandatory order: Steam ID -> player name -> + * coordinates. See class docblock for rationale. + * + * @param string $content Raw log content that may contain PII. + * @return string Content with enabled PII categories replaced by tokens. + */ + public function redact(string $content): string + { + if ($this->redactSteamIds) { + // Steam ID pass added in Task 2 + } + if ($this->redactPlayerNames) { + // Player name pass added in Task 3 + } + if ($this->redactCoordinates) { + // Coordinates pass added in Task 4 + } + return $content; + } +} diff --git a/src/Util/RedactorInterface.php b/src/Util/RedactorInterface.php new file mode 100644 index 0000000..9e8e8fc --- /dev/null +++ b/src/Util/RedactorInterface.php @@ -0,0 +1,20 @@ +