Completed
Push — master ( ccd20f...6ee4e9 )
by dan
02:09
created

Broadcaster::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Broadcast;
4
5
6
use IrishDan\NotificationBundle\Channel\ChannelInterface;
7
use IrishDan\NotificationBundle\Notification\NotifiableInterface;
8
use IrishDan\NotificationBundle\Notification\NotificationInterface;
9
10
class Broadcaster
11
{
12
    protected $notifiable;
13
    protected $channel;
14
    protected $config;
15
16
    public function __construct(BroadcastNotifiableInterface $notifiable, ChannelInterface $channel, array $config)
17
    {
18
        $this->notifiable = $notifiable;
19
        $this->channel    = $channel;
20
21
        // Set the data for Slack Broadcasts
22
        if (!empty($config['webhook'])) {
23
            $notifiable->setSlackWebhook($config['webhook']);
24
        }
25
    }
26
27
    public function send(NotificationInterface $notification)
28
    {
29
        $notification->setNotifiable($this->notifiable);
0 ignored issues
show
Documentation introduced by
$this->notifiable is of type object<IrishDan\Notifica...astNotifiableInterface>, but the function expects a object<IrishDan\Notifica...on\NotifiableInterface>.

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);
Loading history...
30
        $notification->setChannel('slack');
31
32
        $message = $this->channel->format($notification);
33
34
        $this->channel->dispatch($message);
35
    }
36
}