refactor(social): TokenRedactor::redact accepts nullable
Lets the call sites drop the explicit null check ternary. The redactor itself owns the null handling — one less conditional at every caller.
This commit is contained in:
parent
cf80e1fcae
commit
123996bbc0
2 changed files with 6 additions and 2 deletions
|
|
@ -28,7 +28,7 @@ public function context(): array
|
|||
'category' => $this->category->value,
|
||||
'platform_error_code' => $this->platformErrorCode,
|
||||
'user_message' => $this->userMessage,
|
||||
'raw_response' => $this->rawResponse !== null ? TokenRedactor::redact($this->rawResponse) : null,
|
||||
'raw_response' => TokenRedactor::redact($this->rawResponse),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,12 @@
|
|||
*/
|
||||
class TokenRedactor
|
||||
{
|
||||
public static function redact(string $body): string
|
||||
public static function redact(?string $body): ?string
|
||||
{
|
||||
if ($body === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return preg_replace(
|
||||
[
|
||||
'/access_token=([^&"\s]+)/',
|
||||
|
|
|
|||
Loading…
Reference in a new issue