This commit is contained in:
Maxime Renou 2020-05-12 17:25:47 +02:00
parent 98011bf5da
commit 647d1378bb
3 changed files with 23 additions and 16 deletions

View File

@ -24,7 +24,7 @@ class BluescaleMailApi
* @param BluescaleMailTemplate $template * @param BluescaleMailTemplate $template
* @param $notifiable * @param $notifiable
* @return \Psr\Http\Message\StreamInterface * @return \Psr\Http\Message\StreamInterface
* @throws BMailException * @throws BluescaleMailException
*/ */
public function send($template, $notifiable): StreamInterface public function send($template, $notifiable): StreamInterface
{ {

View File

@ -7,16 +7,23 @@ use Psr\Http\Message\StreamInterface;
class BluescaleMailChannel class BluescaleMailChannel
{ {
protected $api;
public function __construct(BluescaleMailApi $api)
{
$this->api = $api;
}
/** /**
* @param $notifiable * @param $notifiable
* @param Notification $notification * @param Notification $notification
* @return \Psr\Http\Message\StreamInterface * @return \Psr\Http\Message\StreamInterface
* @throws BMailException * @throws BluescaleMailException
*/ */
public function send($notifiable, Notification $notification, BluescaleMailApi $api): StreamInterface public function send($notifiable, Notification $notification): StreamInterface
{ {
$template = $notification->toTemplate($notifiable); $template = $notification->toTemplate($notifiable);
return $api->send($template, $notifiable); return $this->api->send($template, $notifiable);
} }
} }

View File

@ -47,9 +47,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param string $address * @param string $address
* @param string|null $name * @param string|null $name
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function sender(string $address, string $name = null): BMailTemplate public function sender(string $address, string $name = null): BluescaleMailTemplate
{ {
$this->sender['address'] = $address; $this->sender['address'] = $address;
@ -62,9 +62,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param string $address * @param string $address
* @param string|null $name * @param string|null $name
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function replyTo(string $address, string $name = null): BMailTemplate public function replyTo(string $address, string $name = null): BluescaleMailTemplate
{ {
$this->replyTo['address'] = $address; $this->replyTo['address'] = $address;
@ -76,9 +76,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param array $recipients * @param array $recipients
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function recipients(array $recipients): BMailTemplate public function recipients(array $recipients): BluescaleMailTemplate
{ {
if (!empty($recipients)) { if (!empty($recipients)) {
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
@ -106,9 +106,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param string $address * @param string $address
* @param array $informations * @param array $informations
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function addRecipient(string $address, array $informations = []): BMailTemplate public function addRecipient(string $address, array $informations = []): BluescaleMailTemplate
{ {
$data = [ $data = [
'address' => $address 'address' => $address
@ -128,9 +128,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param array $parameters * @param array $parameters
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function parameters(array $parameters): BMailTemplate public function parameters(array $parameters): BluescaleMailTemplate
{ {
$this->parameters = $parameters; $this->parameters = $parameters;
return $this; return $this;
@ -139,9 +139,9 @@ class BluescaleMailTemplate implements \JsonSerializable
/** /**
* @param string $key * @param string $key
* @param string $value * @param string $value
* @return BMailTemplate * @return BluescaleMailTemplate
*/ */
public function addParameter(string $key, string $value): BMailTemplate public function addParameter(string $key, string $value): BluescaleMailTemplate
{ {
$this->parameters[$key] = $value; $this->parameters[$key] = $value;
return $this; return $this;