Passed
Push — master ( 3ec735...0b5e67 )
by Chema
01:36 queued 14s
created

SlackChannel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 23
rs 10
ccs 9
cts 9
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 5 1
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTicker\Domain\Notifier\Channel\Slack;
6
7
use Chemaclass\StockTicker\Domain\Notifier\Channel\TemplateGeneratorInterface;
8
use Chemaclass\StockTicker\Domain\Notifier\ChannelInterface;
9
use Chemaclass\StockTicker\Domain\Notifier\NotifyResult;
10
11
final class SlackChannel implements ChannelInterface
12
{
13
    private string $slackDestinyChannelId;
14
15
    private SlackClientInterface $slackClient;
16
17
    private TemplateGeneratorInterface $templateGenerator;
18
19 1
    public function __construct(
20
        string $slackDestinyChannelId,
21
        SlackClientInterface $slackClient,
22
        TemplateGeneratorInterface $templateGenerator
23
    ) {
24 1
        $this->slackClient = $slackClient;
25 1
        $this->slackDestinyChannelId = $slackDestinyChannelId;
26 1
        $this->templateGenerator = $templateGenerator;
27 1
    }
28
29 1
    public function send(NotifyResult $notifyResult): void
30
    {
31 1
        $this->slackClient->postToChannel(
32 1
            $this->slackDestinyChannelId,
33 1
            $this->templateGenerator->generateHtml($notifyResult)
34
        );
35 1
    }
36
}
37