Completed
Pull Request — master (#18)
by Frederik
01:37
created

DkimV1SignedTransport   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 49
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A send() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Transport;
5
6
use Genkgo\Mail\Dkim\HeaderV1Factory;
7
use Genkgo\Mail\Dkim\Parameters;
8
use Genkgo\Mail\MessageInterface;
9
use Genkgo\Mail\TransportInterface;
10
11
final class DkimV1SignedTransport implements TransportInterface
12
{
13
    /**
14
     * @var TransportInterface
15
     */
16
    private $transport;
17
    /**
18
     * @var HeaderV1Factory
19
     */
20
    private $headerFactory;
21
    /**
22
     * @var Parameters
23
     */
24
    private $parameters;
25
26
    /**
27
     * DkimSignedTransport constructor.
28
     * @param TransportInterface $transport
29
     * @param HeaderV1Factory $headerFactory
30
     * @param Parameters $parameters
31
     * @internal param string $domain
32
     * @internal param string $selector
33
     */
34 1
    public function __construct(
35
        TransportInterface $transport,
36
        HeaderV1Factory $headerFactory,
37
        Parameters $parameters
38
    ) {
39 1
        $this->transport = $transport;
40 1
        $this->headerFactory = $headerFactory;
41 1
        $this->parameters = $parameters;
42 1
    }
43
44
    /**
45
     * @param MessageInterface $message
46
     * @return void
47
     */
48 1
    public function send(MessageInterface $message): void
49
    {
50 1
        $this->transport->send(
51 1
            $message->withHeader(
52 1
                $this->headerFactory->factory(
53 1
                    $message,
54 1
                    $this->parameters->withSignatureTimestamp(new \DateTimeImmutable('now'))
55
                )
56
            )
57
        );
58
    }
59
}