Skip to content

Commit 2545455

Browse files
committed
Added: PHP version to user-agent header
1 parent ee8390e commit 2545455

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Client {
1515
public const DEFAULT_URL = 'https://sms.capcom.me/api/3rdparty/v1';
16-
public const USER_AGENT = 'android-sms-gateway/1.0 (client; php)';
16+
public const USER_AGENT_TEMPLATE = 'android-sms-gateway/1.0 (client; php %s)';
1717

1818
protected string $basicAuth;
1919
protected string $baseUrl;
@@ -105,7 +105,7 @@ protected function sendRequest(string $method, string $path, $payload = null) {
105105
$this->baseUrl . $path
106106
)
107107
->withAddedHeader('Authorization', 'Basic ' . $this->basicAuth)
108-
->withAddedHeader('User-Agent', self::USER_AGENT);
108+
->withAddedHeader('User-Agent', sprintf(self::USER_AGENT_TEMPLATE, PHP_VERSION));
109109
if (isset($data)) {
110110
$request = $request
111111
->withAddedHeader('Content-Type', 'application/json')

tests/ClientTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function testSend(): void {
5656
'application/json',
5757
$req->getHeaderLine('Content-Type')
5858
);
59+
$this->assertEquals(
60+
sprintf(Client::USER_AGENT_TEMPLATE, PHP_VERSION),
61+
$req->getHeaderLine('User-Agent')
62+
);
5963

6064

6165
$this->assertInstanceOf(MessageState::class, $messageState);

0 commit comments

Comments
 (0)