Skip to content

Commit b6b9d86

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Notifier] Use CPP
1 parent 8bdd9ab commit b6b9d86

23 files changed

+95
-149
lines changed

Channel/BrowserChannel.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@
2222
*/
2323
final class BrowserChannel implements ChannelInterface
2424
{
25-
private RequestStack $stack;
26-
27-
private FlashMessageImportanceMapperInterface $mapper;
28-
29-
public function __construct(RequestStack $stack, FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper())
30-
{
31-
$this->stack = $stack;
32-
$this->mapper = $mapper;
25+
public function __construct(
26+
private RequestStack $stack,
27+
private FlashMessageImportanceMapperInterface $mapper = new DefaultFlashMessageImportanceMapper(),
28+
) {
3329
}
3430

3531
public function notify(Notification $notification, RecipientInterface $recipient, string $transportName = null): void

Channel/ChannelPolicy.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
final class ChannelPolicy implements ChannelPolicyInterface
2020
{
21-
private array $policy;
22-
23-
public function __construct(array $policy)
24-
{
25-
$this->policy = $policy;
21+
public function __construct(
22+
private array $policy,
23+
) {
2624
}
2725

2826
public function getChannels(string $importance): array

Channel/EmailChannel.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@
2929
*/
3030
class EmailChannel implements ChannelInterface
3131
{
32-
private ?TransportInterface $transport;
33-
private ?MessageBusInterface $bus;
3432
private string|Address|null $from;
35-
private ?Envelope $envelope;
3633

37-
public function __construct(TransportInterface $transport = null, MessageBusInterface $bus = null, string $from = null, Envelope $envelope = null)
38-
{
34+
public function __construct(
35+
private ?TransportInterface $transport = null,
36+
private ?MessageBusInterface $bus = null,
37+
string $from = null,
38+
private ?Envelope $envelope = null,
39+
) {
3940
if (null === $transport && null === $bus) {
4041
throw new LogicException(sprintf('"%s" needs a Transport or a Bus but both cannot be "null".', static::class));
4142
}
4243

43-
$this->transport = $transport;
44-
$this->bus = $bus;
4544
$this->from = $from ?: $envelope?->getSender();
46-
$this->envelope = $envelope;
4745
}
4846

4947
/**

Chatter.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@
2323
*/
2424
final class Chatter implements ChatterInterface
2525
{
26-
private TransportInterface $transport;
27-
private ?MessageBusInterface $bus;
28-
private ?EventDispatcherInterface $dispatcher;
29-
30-
public function __construct(TransportInterface $transport, MessageBusInterface $bus = null, EventDispatcherInterface $dispatcher = null)
31-
{
32-
$this->transport = $transport;
33-
$this->bus = $bus;
34-
$this->dispatcher = $dispatcher;
26+
public function __construct(
27+
private TransportInterface $transport,
28+
private ?MessageBusInterface $bus = null,
29+
private ?EventDispatcherInterface $dispatcher = null,
30+
) {
3531
}
3632

3733
public function __toString(): string

DataCollector/NotificationDataCollector.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@
2222
*/
2323
final class NotificationDataCollector extends DataCollector
2424
{
25-
private NotificationLoggerListener $logger;
26-
27-
public function __construct(NotificationLoggerListener $logger)
28-
{
29-
$this->logger = $logger;
25+
public function __construct(
26+
private NotificationLoggerListener $logger,
27+
) {
3028
}
3129

3230
public function collect(Request $request, Response $response, \Throwable $exception = null): void

Event/FailedMessageEvent.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
final class FailedMessageEvent extends Event
2121
{
22-
private MessageInterface $message;
23-
private \Throwable $error;
24-
25-
public function __construct(MessageInterface $message, \Throwable $error)
26-
{
27-
$this->message = $message;
28-
$this->error = $error;
22+
public function __construct(
23+
private MessageInterface $message,
24+
private \Throwable $error,
25+
) {
2926
}
3027

3128
public function getMessage(): MessageInterface

Event/MessageEvent.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
*/
2020
final class MessageEvent extends Event
2121
{
22-
private MessageInterface $message;
23-
private bool $queued;
24-
25-
public function __construct(MessageInterface $message, bool $queued = false)
26-
{
27-
$this->message = $message;
28-
$this->queued = $queued;
22+
public function __construct(
23+
private MessageInterface $message,
24+
private bool $queued = false,
25+
) {
2926
}
3027

3128
public function getMessage(): MessageInterface

Event/SentMessageEvent.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
*/
2020
final class SentMessageEvent extends Event
2121
{
22-
private SentMessage $message;
23-
24-
public function __construct(SentMessage $message)
25-
{
26-
$this->message = $message;
22+
public function __construct(
23+
private SentMessage $message,
24+
) {
2725
}
2826

2927
public function getMessage(): SentMessage

EventListener/SendFailedMessageToNotifierListener.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
class SendFailedMessageToNotifierListener implements EventSubscriberInterface
2626
{
27-
private Notifier $notifier;
28-
29-
public function __construct(Notifier $notifier)
30-
{
31-
$this->notifier = $notifier;
27+
public function __construct(
28+
private Notifier $notifier,
29+
) {
3230
}
3331

3432
public function onMessageFailed(WorkerMessageFailedEvent $event): void

Exception/IncompleteDsnException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717
class IncompleteDsnException extends InvalidArgumentException
1818
{
19-
private ?string $dsn;
20-
21-
public function __construct(string $message, string $dsn = null, \Throwable $previous = null)
22-
{
23-
$this->dsn = $dsn;
19+
public function __construct(
20+
string $message,
21+
private ?string $dsn = null,
22+
\Throwable $previous = null,
23+
) {
2424
if ($dsn) {
2525
$message = sprintf('Invalid "%s" notifier DSN: %s', $dsn, $message);
2626
}

0 commit comments

Comments
 (0)