Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a759e08

Browse files
committed
-
1 parent 3072e05 commit a759e08

12 files changed

+32
-33
lines changed

src/Symfony/Component/Mailer/Bridge/Mailgun/Webhook/MailgunRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
final class MailgunRequestParser extends AbstractRequestParser
2626
{
2727
public function __construct(
28-
private MailgunPayloadConverter $converter,
28+
private readonly MailgunPayloadConverter $converter,
2929
) {
3030
}
3131

src/Symfony/Component/Mailer/Bridge/Postmark/Webhook/PostmarkRequestParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
final class PostmarkRequestParser extends AbstractRequestParser
2727
{
2828
public function __construct(
29-
private PostmarkPayloadConverter $converter,
29+
private readonly PostmarkPayloadConverter $converter,
3030
) {
3131
}
3232

src/Symfony/Component/Notifier/Bridge/Twilio/TwilioOptions.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515

1616
final class TwilioOptions implements MessageOptionsInterface
1717
{
18-
private array $options;
19-
20-
public function __construct(array $options = [])
21-
{
22-
$this->options = $options;
18+
public function __construct(
19+
private array $options = [],
20+
) {
2321
}
2422

2523
public function toArray(): array

src/Symfony/Component/RemoteEvent/Messenger/ConsumeRemoteEventHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class ConsumeRemoteEventHandler
2323
{
2424
public function __construct(
25-
private ContainerInterface $consumers,
25+
private readonly ContainerInterface $consumers,
2626
) {
2727
}
2828

src/Symfony/Component/RemoteEvent/Messenger/ConsumeRemoteEventMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getType(): string
3131
return $this->type;
3232
}
3333

34-
public function getEvent(): Event
34+
public function getEvent(): RemoteEvent
3535
{
3636
return $this->event;
3737
}

src/Symfony/Component/Webhook/Messenger/SendWebhookHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class SendWebhookHandler
2222
{
2323
public function __construct(
24-
private TransportInterface $transport,
24+
private readonly TransportInterface $transport,
2525
) {
2626
}
2727

src/Symfony/Component/Webhook/Messenger/SendWebhookMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
class SendWebhookMessage
2323
{
2424
public function __construct(
25-
private Subscriber $subscriber,
26-
private RemoteEvent $event,
25+
private readonly Subscriber $subscriber,
26+
private readonly RemoteEvent $event,
2727
) {
2828
}
2929

src/Symfony/Component/Webhook/Server/HeaderSignatureGenerator.php renamed to src/Symfony/Component/Webhook/Server/HeaderSignatureConfigurator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
*
2121
* @experimental in 6.3
2222
*/
23-
final class HeaderSignatureGenerator implements GeneratorInterface
23+
final class HeaderSignatureConfigurator implements RequestConfiguratorInterface
2424
{
2525
public function __construct(
26-
private readonly string $algo = 'sha256',
27-
private readonly string $signatureHeaderName = 'Webhook-Signature',
26+
private string $algo = 'sha256',
27+
private string $signatureHeaderName = 'Webhook-Signature',
2828
) {
2929
}
3030

31-
public function generate(RemoteEvent $event, string $secret, HttpOptions $options): void
31+
public function configure(RemoteEvent $event, string $secret, HttpOptions $options): void
3232
{
3333
$opts = $options->toArray();
3434
$headers = $opts['headers'];

src/Symfony/Component/Webhook/Server/HeadersGenerator.php renamed to src/Symfony/Component/Webhook/Server/HeadersConfigurator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
*
2020
* @experimental in 6.3
2121
*/
22-
final class HeadersGenerator implements GeneratorInterface
22+
final class HeadersConfigurator implements RequestConfiguratorInterface
2323
{
2424
public function __construct(
25-
private readonly string $eventHeaderName = 'Webhook-Event',
26-
private readonly string $idHeaderName = 'Webhook-Id',
25+
private string $eventHeaderName = 'Webhook-Event',
26+
private string $idHeaderName = 'Webhook-Id',
2727
) {
2828
}
2929

30-
public function generate(RemoteEvent $event, string $secret, HttpOptions $options): void
30+
public function configure(RemoteEvent $event, string $secret, HttpOptions $options): void
3131
{
3232
$options->setHeaders([
3333
$this->eventHeaderName => $event->getName(),

src/Symfony/Component/Webhook/Server/JsonBodyGenerator.php renamed to src/Symfony/Component/Webhook/Server/JsonBodyConfigurator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
*
2121
* @experimental in 6.3
2222
*/
23-
final class JsonBodyGenerator implements GeneratorInterface
23+
final class JsonBodyConfigurator implements RequestConfiguratorInterface
2424
{
2525
public function __construct(
26-
private SerializerInterface $serializer,
26+
private readonly SerializerInterface $serializer,
2727
) {
2828
}
2929

30-
public function generate(RemoteEvent $event, string $secret, HttpOptions $options): void
30+
public function configure(RemoteEvent $event, string $secret, HttpOptions $options): void
3131
{
3232
$body = $this->serializer->serialize($event->getPayload(), 'json');
3333
$options->setBody($body);

src/Symfony/Component/Webhook/Server/GeneratorInterface.php renamed to src/Symfony/Component/Webhook/Server/RequestConfiguratorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
* @experimental in 6.3
2121
*/
22-
interface GeneratorInterface
22+
interface RequestConfiguratorInterface
2323
{
24-
public function generate(RemoteEvent $event, string $secret, HttpOptions $options): void;
24+
public function configure(RemoteEvent $event, string $secret, HttpOptions $options): void;
2525
}

src/Symfony/Component/Webhook/Server/Transport.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@
2424
class Transport implements TransportInterface
2525
{
2626
public function __construct(
27-
private HttpClientInterface $client,
28-
private GeneratorInterface $headersGenerator,
29-
private GeneratorInterface $bodyGenerator,
30-
private GeneratorInterface $signer,
27+
private readonly HttpClientInterface $client,
28+
private readonly RequestConfiguratorInterface $headers,
29+
private readonly RequestConfiguratorInterface $body,
30+
private readonly RequestConfiguratorInterface $signer,
3131
) {
3232
}
3333

3434
public function send(Subscriber $subscriber, RemoteEvent $event): void
3535
{
36-
// FIXME: Add a version?
3736
$options = new HttpOptions();
38-
$this->headersGenerator->generate($event, $subscriber->getSecret(), $options);
39-
$this->bodyGenerator->generate($event, $subscriber->getSecret(), $options);
40-
$this->signer->generate($event, $subscriber->getSecret(), $options);
37+
38+
$this->headers->configure($event, $subscriber->getSecret(), $options);
39+
$this->body->configure($event, $subscriber->getSecret(), $options);
40+
$this->signer->configure($event, $subscriber->getSecret(), $options);
41+
4142
$this->client->request('POST', $subscriber->getUrl(), $options->toArray());
4243
}
4344
}

0 commit comments

Comments
 (0)