for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Anton Tuyakhov <[email protected]>
*/
namespace tuyakhov\notifications\channels;
use tuyakhov\notifications\messages\DatabaseMessage;
use tuyakhov\notifications\NotifiableInterface;
use tuyakhov\notifications\NotificationInterface;
use yii\base\Component;
use yii\db\ActiveRecordInterface;
use yii\di\Instance;
class ActiveRecordChannel extends Component implements ChannelInterface
{
* @var ActiveRecordInterface|string
public $model = 'tuyakhov\notifications\models\DatabaseNotification';
* @throws \yii\base\InvalidConfigException
public function init()
parent::init();
$this->model = Instance::ensure($this->model, 'yii\db\ActiveRecordInterface');
}
public function send(NotifiableInterface $recipient, NotificationInterface $notification)
/** @var DatabaseMessage $message */
$message = $notification->exportFor('database');
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
list($notifiableType, $notifiableId) = $recipient->routeNotificationFor('database');
$this->model->insert(true, [
'level' => $message->level,
'subject' => $message->subject,
'body' => $message->body,
'notifiable_type' => $notifiableType,
'notifiable_id' => $notifiableId,
]);
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.