Skip to content

Commit

Permalink
Ensure the user agent is always a string
Browse files Browse the repository at this point in the history
  • Loading branch information
kleiram committed Mar 10, 2020
1 parent d44ff46 commit 276ae6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public static function setHttp(HttpInterface $http): void
/**
* Set the user agent reported with API calls.
*
* @param string|null $userAgent
* @param string $userAgent
*/
public static function setUserAgent(?string $userAgent): void
public static function setUserAgent(string $userAgent): void
{
static::$userAgent = $userAgent;
}
Expand All @@ -132,7 +132,7 @@ private static function addAuthenticationOptions(array $options): array

private static function addUserAgentOptions(array $options): array
{
if (static::$userAgent === null) {
if (static::$userAgent === null || strlen(static::$userAgent) === 0) {
return $options;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setup(): void

public function tearDown(): void
{
Client::setUserAgent(null);
Client::setUserAgent('');
}

public function testAuthenticateWithCredentials()
Expand Down

0 comments on commit 276ae6f

Please sign in to comment.