Completed
Push — master ( 1469eb...32b27e )
by Frederik
02:28
created

DkimV1SignedTransport::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
crap 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
     */
32 1
    public function __construct(
33
        TransportInterface $transport,
34
        HeaderV1Factory $headerFactory,
35
        Parameters $parameters
36
    ) {
37 1
        $this->transport = $transport;
38 1
        $this->headerFactory = $headerFactory;
39 1
        $this->parameters = $parameters;
40 1
    }
41
42
    /**
43
     * @param MessageInterface $message
44
     * @return void
45
     */
46 1
    public function send(MessageInterface $message): void
47
    {
48 1
        $this->transport->send(
49 1
            $message->withHeader(
50 1
                $this->headerFactory->factory(
51 1
                    $message,
52 1
                    $this->parameters->withSignatureTimestamp(new \DateTimeImmutable('now'))
53
                )
54
            )
55
        );
56
    }
57
}