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\SlackMessage;
use tuyakhov\notifications\NotifiableInterface;
use tuyakhov\notifications\NotificationInterface;
use yii\base\Component;
use yii\di\Instance;
use yii\helpers\ArrayHelper;
use yii\httpclient\Client;
use yii\httpclient\Response;
class SlackChannel extends Component implements ChannelInterface
{
* @var Client|array|string
public $httpClient;
* @inheritdoc
public function init()
parent::init();
if (!isset($this->httpClient)) {
$this->httpClient = [
'class' => Client::className(),
yii\base\BaseObject::className()
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
'class' => /** @scrutinizer ignore-deprecated */ Client::className(),
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
];
}
$this->httpClient = Instance::ensure($this->httpClient, Client::className());
$this->httpClient = Instance::ensure($this->httpClient, /** @scrutinizer ignore-deprecated */ Client::className());
* @param NotifiableInterface $recipient
* @param NotificationInterface $notification
* @return Response
public function send(NotifiableInterface $recipient, NotificationInterface $notification)
/** @var SlackMessage $message */
$message = $notification->exportFor('slack');
$webhookUrl = $recipient->routeNotificationFor('slack');
$text = "*{$message->subject}*\n{$message->body}";
return $this->httpClient->createRequest()
->setMethod('post')
->setUrl($webhookUrl)
->setData(ArrayHelper::merge(['text' => $text], $message->arguments))
->send();
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.