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

SlackChannel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 8
rs 10
ccs 4
cts 4
cp 1
crap 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