Skip to content

Commit 328821b

Browse files
committed
chore: apply code formatting and cleanup
Refactored code for consistent formatting and spacing, improving readability and maintaining compliance with PHPDoc standards. Updated minor code constructs to align with PHP best practices and removed redundant whitespace. These changes ensure a more standardized codebase.
1 parent 7cde2fc commit 328821b

5 files changed

Lines changed: 20 additions & 18 deletions

File tree

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "lettermint/lettermint-php",
3-
"version": "1.4.99",
43
"description": "Official Lettermint PHP SDK.",
54
"type": "library",
65
"keywords": [

src/Exceptions/TimestampToleranceException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace Lettermint\Exceptions;
44

5-
class TimestampToleranceException extends WebhookVerificationException
6-
{
7-
}
5+
class TimestampToleranceException extends WebhookVerificationException {}

src/Lettermint.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
namespace Lettermint;
44

5-
use Lettermint\Endpoints\EmailEndpoint;
65
use Lettermint\Client\HttpClient;
6+
use Lettermint\Endpoints\EmailEndpoint;
77

88
/**
99
* @property-read EmailEndpoint $email Access the send endpoint {@see EmailEndpoint}
1010
*/
1111
class Lettermint
1212
{
1313
private string $apiToken;
14+
1415
private string $baseUrl;
16+
1517
private HttpClient $httpClient;
18+
1619
private array $endpoints = [];
1720

1821
protected array $endpointRegistry = [
@@ -35,6 +38,7 @@ public function __get($name)
3538
if (array_key_exists($name, $this->endpointRegistry)) {
3639
$class = $this->endpointRegistry[$name];
3740
$this->endpoints[$name] = new $class($this->httpClient);
41+
3842
return $this->endpoints[$name];
3943
}
4044

src/Webhook.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ final class Webhook
2222
/**
2323
* Create a new webhook verifier instance.
2424
*
25-
* @param string $secret The webhook signing secret
26-
* @param int $tolerance Maximum allowed time difference in seconds (default: 300)
25+
* @param string $secret The webhook signing secret
26+
* @param int $tolerance Maximum allowed time difference in seconds (default: 300)
2727
*
2828
* @throws \InvalidArgumentException If secret is empty
2929
*/
@@ -40,9 +40,9 @@ public function __construct(string $secret, int $tolerance = self::DEFAULT_TOLER
4040
/**
4141
* Verify a webhook signature and return the decoded payload.
4242
*
43-
* @param string $payload The raw request body
44-
* @param string $signature The signature header value (format: t={timestamp},v1={hash})
45-
* @param int|null $timestamp Optional timestamp from delivery header for cross-validation
43+
* @param string $payload The raw request body
44+
* @param string $signature The signature header value (format: t={timestamp},v1={hash})
45+
* @param int|null $timestamp Optional timestamp from delivery header for cross-validation
4646
* @return array<string, mixed> The decoded webhook payload
4747
*
4848
* @throws WebhookVerificationException If signature format is invalid or timestamps mismatch
@@ -82,8 +82,8 @@ public function verify(string $payload, string $signature, ?int $timestamp = nul
8282
/**
8383
* Verify a webhook using HTTP headers and return the decoded payload.
8484
*
85-
* @param array<string, string> $headers HTTP headers from the request
86-
* @param string $payload The raw request body
85+
* @param array<string, string> $headers HTTP headers from the request
86+
* @param string $payload The raw request body
8787
* @return array<string, mixed> The decoded webhook payload
8888
*
8989
* @throws WebhookVerificationException If required headers are missing or verification fails
@@ -112,11 +112,11 @@ public function verifyHeaders(array $headers, string $payload): array
112112
/**
113113
* Static convenience method to verify a webhook signature.
114114
*
115-
* @param string $payload The raw request body
116-
* @param string $signature The signature header value (format: t={timestamp},v1={hash})
117-
* @param string $secret The webhook signing secret
118-
* @param int|null $timestamp Optional timestamp from delivery header for cross-validation
119-
* @param int $tolerance Maximum allowed time difference in seconds (default: 300)
115+
* @param string $payload The raw request body
116+
* @param string $signature The signature header value (format: t={timestamp},v1={hash})
117+
* @param string $secret The webhook signing secret
118+
* @param int|null $timestamp Optional timestamp from delivery header for cross-validation
119+
* @param int $tolerance Maximum allowed time difference in seconds (default: 300)
120120
* @return array<string, mixed> The decoded webhook payload
121121
*
122122
* @throws \InvalidArgumentException If secret is empty

tests/WebhookTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
function generateValidSignature(string $payload, int $timestamp, string $secret = TEST_SECRET): string
1313
{
14-
$signedContent = $timestamp . '.' . $payload;
14+
$signedContent = $timestamp.'.'.$payload;
1515
$signature = hash_hmac('sha256', $signedContent, $secret);
16+
1617
return "t={$timestamp},v1={$signature}";
1718
}
1819

0 commit comments

Comments
 (0)