Completed
Pull Request — master (#18)
by Frederik
03:05
created

DkimV1SignedTransport::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Transport;
5
6
use Genkgo\Mail\Dkim\HeaderV1Factory;
7
use Genkgo\Mail\MessageInterface;
8
use Genkgo\Mail\TransportInterface;
9
10
final class DkimV1SignedTransport implements TransportInterface
11
{
12
    /**
13
     * @var TransportInterface
14
     */
15
    private $transport;
16
    /**
17
     * @var HeaderV1Factory
18
     */
19
    private $headerFactory;
20
    /**
21
     * @var string
22
     */
23
    private $domain;
24
    /**
25
     * @var string
26
     */
27
    private $selector;
28
29
    /**
30
     * DkimSignedTransport constructor.
31
     * @param TransportInterface $transport
32
     * @param HeaderV1Factory $headerFactory
33
     * @param string $domain
34
     * @param string $selector
35
     */
36
    public function __construct(
37
        TransportInterface $transport,
38
        HeaderV1Factory $headerFactory,
39
        string $domain,
40
        string $selector
41
    ) {
42
        $this->transport = $transport;
43
        $this->headerFactory = $headerFactory;
44
        $this->domain = $domain;
45
        $this->selector = $selector;
46
    }
47
48
    /**
49
     * @param MessageInterface $message
50
     * @return void
51
     */
52
    public function send(MessageInterface $message): void
53
    {
54
        $this->transport->send(
55
            $message->withHeader(
56
                $this->headerFactory->factory(
57
                    $message,
58
                    $this->domain,
59
                    $this->selector
60
                )
61
            )
62
        );
63
    }
64
}