Skip to content

Commit 27ef3ff

Browse files
authored
Merge pull request #58 from ppavlovic/master
Improvement: Obfuscate params can be array of callables instead of just an array of fields
2 parents 7e64a95 + d87ce23 commit 27ef3ff

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Data/Request.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ private function obfuscateParams(array $params)
7272
{
7373
\parse_str(\trim(\file_get_contents('php://input')), $rawBodyParams);
7474

75-
foreach($this->paramsToObfuscate as $key) {
76-
if (isset($params[$key])) {
77-
$params[$key] = '*****';
75+
foreach($this->paramsToObfuscate as $key => $value) {
76+
$paramIndex = is_int($key) ? $value : $key;
77+
if (isset($params[$paramIndex])) {
78+
$params[$paramIndex] = is_callable($value) ? $value($params[$paramIndex]) : '*****';
7879
}
79-
if (is_array($rawBodyParams) && \array_key_exists($key, $rawBodyParams)) {
80-
$rawBodyParams[$key] = '_obfuscated_';
80+
if (is_array($rawBodyParams) && \array_key_exists($paramIndex, $rawBodyParams)) {
81+
$rawBodyParams[$paramIndex] = is_callable($value) ? $value($rawBodyParams[$paramIndex]) : '__obfuscated__';
8182
}
8283
}
8384

0 commit comments

Comments
 (0)