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

Notifier   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 8 3
A sendVia() 0 8 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