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 @@ +