Skip to content

Commit

Permalink
fix: Update RequestOptions#redactedApiKey to stop exploding null. (#1289
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dcr-stripe authored May 23, 2022
1 parent 47cfc40 commit 3a95278
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Util/RequestOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ public static function parse($options, $strict = false)
throw new \Stripe\Exception\InvalidArgumentException($message);
}

/** @return string */
private function redactedApiKey()
{
if (null === $this->apiKey) {
return '';
}

$pieces = \explode('_', $this->apiKey, 3);
$last = \array_pop($pieces);
$redactedLast = \strlen($last) > 4
Expand Down
4 changes: 4 additions & 0 deletions tests/Stripe/Util/RequestOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,9 @@ public function testDebugInfo()
$opts = RequestOptions::parse(['api_key' => '1234567890abcdefghijklmn']);
$debugInfo = \print_r($opts, true);
static::compatAssertStringContainsString('[apiKey] => ********************klmn', $debugInfo);

$opts = RequestOptions::parse([]);
$debugInfo = \print_r($opts, true);
static::compatAssertStringContainsString("[apiKey] => \n", $debugInfo);
}
}

0 comments on commit 3a95278

Please sign in to comment.