Completed
Push — master ( 947cff...af97d0 )
by Nikola
04:03
created

Notifier::sendVia()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Notifier;
6
7
use Notifier\Channel\Channels;
8
use Notifier\Notification\Notification;
9
use Notifier\Recipient\Recipients;
10
11
class Notifier
12
{
13
    /** @var Channels */
14
    protected $channels;
15
16 3
    public function __construct(Channels $channels)
17
    {
18 3
        $this->channels = $channels;
19 3
    }
20
21 1
    public function send(Notification $notification, Recipients $recipients): void
22
    {
23 1
        foreach ($recipients as $recipient) {
24 1
            foreach ($this->channels as $channel) {
25 1
                $channel->send($notification, $recipient);
26
            }
27
        }
28 1
    }
29
30 2
    public function sendVia(string $channelName, Notification $notification, Recipients $recipients): void
31
    {
32 2
        $channel = $this->channels->get($channelName);
33
34 1
        foreach ($recipients as $recipient) {
35 1
            $channel->send($notification, $recipient);
36
        }
37 1
    }
38
}
39