Skip to content

Commit

Permalink
renamed Nette\Mail\IMailer -> Mailer, added class alias
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 3, 2019
1 parent 102ff80 commit d109c9e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -31,7 +31,8 @@
"ext-fileinfo": "to detect type of attached files"
},
"autoload": {
"classmap": ["src/"]
"classmap": ["src/"],
"files": ["src/compatibility.php"]
},
"minimum-stability": "dev",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -107,4 +107,4 @@ $mailer = new Nette\Mail\SmtpMailer([
$mailer->send($mail);
```

You can also create your own mailer - it's a class implementing Nette\Mail\IMailer interface.
You can also create your own mailer - it's a class implementing Nette\Mail\Mailer interface.
2 changes: 1 addition & 1 deletion src/Bridges/MailDI/MailExtension.php
Expand Up @@ -40,7 +40,7 @@ public function loadConfiguration()
$builder = $this->getContainerBuilder();

$mailer = $builder->addDefinition($this->prefix('mailer'))
->setType(Nette\Mail\IMailer::class);
->setType(Nette\Mail\Mailer::class);

if ($this->config['smtp']) {
$mailer->setFactory(Nette\Mail\SmtpMailer::class, [$this->config]);
Expand Down
10 changes: 5 additions & 5 deletions src/Mail/FallbackMailer.php
Expand Up @@ -12,14 +12,14 @@
use Nette;


class FallbackMailer implements IMailer
class FallbackMailer implements Mailer
{
use Nette\SmartObject;

/** @var callable[] function (FallbackMailer $sender, SendException $e, IMailer $mailer, Message $mail): void */
/** @var callable[] function (FallbackMailer $sender, SendException $e, Mailer $mailer, Message $mail): void */
public $onFailure;

/** @var IMailer[] */
/** @var Mailer[] */
private $mailers;

/** @var int */
Expand All @@ -30,7 +30,7 @@ class FallbackMailer implements IMailer


/**
* @param IMailer[] $mailers
* @param Mailer[] $mailers
* @param int $retryWaitTime in miliseconds
*/
public function __construct(array $mailers, int $retryCount = 3, int $retryWaitTime = 1000)
Expand Down Expand Up @@ -77,7 +77,7 @@ public function send(Message $mail): void
/**
* @return static
*/
public function addMailer(IMailer $mailer)
public function addMailer(Mailer $mailer)
{
$this->mailers[] = $mailer;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Mail/IMailer.php → src/Mail/Mailer.php
Expand Up @@ -13,7 +13,7 @@
/**
* Mailer interface.
*/
interface IMailer
interface Mailer
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Mail/SendmailMailer.php
Expand Up @@ -15,7 +15,7 @@
/**
* Sends emails via the PHP internal mail() function.
*/
class SendmailMailer implements IMailer
class SendmailMailer implements Mailer
{
use Nette\SmartObject;

Expand Down
2 changes: 1 addition & 1 deletion src/Mail/SmtpMailer.php
Expand Up @@ -15,7 +15,7 @@
/**
* Sends emails via the SMTP server.
*/
class SmtpMailer implements IMailer
class SmtpMailer implements Mailer
{
use Nette\SmartObject;

Expand Down
10 changes: 10 additions & 0 deletions src/compatibility.php
@@ -0,0 +1,10 @@
<?php

/**
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/

declare(strict_types=1);

class_alias(Nette\Mail\Mailer::class, Nette\Mail\IMailer::class);

2 comments on commit d109c9e

@petrparolek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@mabar
Copy link

@mabar mabar commented on d109c9e Feb 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefixes and Interface suffixes have no added value. For user does not matter if he's using class or interface and in case of extending or implementing you should know implementation details anyway. It looks cleaner without it.

Please sign in to comment.