Skip to content

Commit

Permalink
fix: check
Browse files Browse the repository at this point in the history
loks0n committed Oct 11, 2024
1 parent c489247 commit 6c7449d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Logger/Log.php
Original file line number Diff line number Diff line change
@@ -382,15 +382,22 @@ public function setMasked(array $masked): void
$this->masked = $masked;
}

/**
* @template T
*
* @param array<string, T> $data
* @return array<string, T|string>
*/
private function mask(array $data): array
{
$masked = [];

foreach ($data as $key => $value) {
if (is_string($key) && in_array($key, $this->masked, true)) {
if (is_string($value) && in_array($key, $this->masked, true)) {
$masked[$key] = str_repeat('*', strlen($value));
} elseif (is_array($value)) {
$masked[$key] = $this->mask($value);
$maskedValue = $this->mask($value); /** @var T $maskedValue */
$masked[$key] = $maskedValue;
} else {
$masked[$key] = $value;
}

0 comments on commit 6c7449d

Please sign in to comment.