for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace nyx\notify\transports;
// External dependencies
use nyx\utils;
// Internal dependencies
use nyx\notify\interfaces;
/**
* Mail Transport
*
* @package Nyx\Notify
* @version 0.1.0
* @author Michal Chojnacki <[email protected]>
* @copyright 2012-2017 Nyx Dev Team
* @link https://github.com/unyx/nyx
*/
class Mail implements interfaces\Transport
{
* @var mail\interfaces\Mailer The Mailer in use for sending out Messages.
protected $mailer;
* Creates a new Mail Transport instance.
* @param mail\interfaces\Mailer $mailer The Mailer to use for sending out Messages.
public function __construct(mail\interfaces\Mailer $mailer)
$this->mailer = $mailer;
}
* {@inheritDoc}
public function send(interfaces\Notifiable $notifiable, interfaces\Notification $notification)
/* @var mail\interfaces\Mailable $notification */
if (!$this->supports($notification)) {
$notification
object<nyx\notify\transp...il\interfaces\Mailable>
object<nyx\notify\interfaces\Notification>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
throw new \InvalidArgumentException('The given Notification is not supported (did you forget to implement the Mailable Interface?).');
if (false === $notifiable->routeNotification('mail', $message = $notification->toMail($notifiable))) {
return;
// The Notification might have built a subject during the toMail() call, but that's optional.
// If no subject is available, we are going to use the humanized name of the Notification's class.
if (empty($message->getSubject())) {
$message->setSubject(utils\str\Cases::title(utils\str\Cases::delimit(class_basename($notification), ' ')));
// And finally - just send the message.
$this->mailer->send($message);
public function supports(interfaces\Notification $notification) : bool
return ($notification instanceof mail\interfaces\Mailable);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: