Skip to content

Commit

Permalink
Annotations and constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
h4kuna authored and f3l1x committed Aug 28, 2023
1 parent bd47814 commit 19e78bf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
9 changes: 3 additions & 6 deletions src/Mailer/CompositeMailer.php
Expand Up @@ -9,14 +9,11 @@
class CompositeMailer implements Mailer
{

/** @var Mailer[] */
/** @var array<Mailer> */
private array $mailers = [];

private bool $silent;

public function __construct(bool $silent = false)
public function __construct(private bool $silent = false)
{
$this->silent = $silent;
}

public function add(Mailer $mailer): void
Expand All @@ -25,7 +22,7 @@ public function add(Mailer $mailer): void
}

/**
* @throw Exception
* @throws Throwable
*/
public function send(Message $mail): void
{
Expand Down
13 changes: 2 additions & 11 deletions src/Mailer/DevOpsMailer.php
Expand Up @@ -8,22 +8,13 @@
class DevOpsMailer implements Mailer
{

private Mailer $mailer;

private string $mail;

public function __construct(Mailer $mailer, string $mail)
public function __construct(private Mailer $mailer, private string $mail)
{
$this->mailer = $mailer;
$this->mail = $mail;
}

/**
* Sends email
*/
public function send(Message $mail): void
{
/** @var callable(string): string[] $getHeaders */
/** @var callable(string): array<string> $getHeaders */
$getHeaders = static fn (string $name) => (array) $mail->getHeader($name);

// Set original To, Cc, Bcc
Expand Down
3 changes: 0 additions & 3 deletions src/Mailer/SendmailMailer.php
Expand Up @@ -24,9 +24,6 @@ public function setBounceMail(string $bounceMail): void
$this->bounceMail = $bounceMail;
}

/**
* Sends email
*/
public function send(Message $mail): void
{
if ($this->bounceMail !== null) {
Expand Down
12 changes: 3 additions & 9 deletions src/Mailer/TraceableMailer.php
Expand Up @@ -8,19 +8,13 @@
class TraceableMailer implements Mailer
{

private Mailer $mailer;

/** @var Message[] */
/** @var array<Message> */
private array $mails = [];

public function __construct(Mailer $mailer)
public function __construct(private Mailer $mailer)
{
$this->mailer = $mailer;
}

/**
* Sends email
*/
public function send(Message $mail): void
{
// Trace sent mails
Expand All @@ -31,7 +25,7 @@ public function send(Message $mail): void
}

/**
* @return Message[]
* @return array<Message>
*/
public function getMails(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Message/Message.php
Expand Up @@ -8,7 +8,7 @@ class Message extends NMessage
{

/**
* @param string[] $receivers
* @param array<string, string|null> $receivers
*/
public function addTos(array $receivers): void
{
Expand Down

0 comments on commit 19e78bf

Please sign in to comment.