FileTransport::send()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Transport;
5
6
use Genkgo\Mail\MessageInterface;
7
use Genkgo\Mail\TransportInterface;
8
9
class FileTransport implements TransportInterface
10
{
11
    /**
12
     * @var FileTransportOptions
13
     */
14
    private $fileTransportOptions;
15
16
    /**
17
     * @param FileTransportOptions $fileTransportOptions
18
     */
19 1
    public function __construct(FileTransportOptions $fileTransportOptions)
20
    {
21 1
        $this->fileTransportOptions = $fileTransportOptions;
22 1
    }
23
24
    /**
25
     * @param MessageInterface $message
26
     */
27 1
    public function send(MessageInterface $message): void
28
    {
29 1
        $fileName = \sprintf(
30 1
            '%s/%s',
31 1
            $this->fileTransportOptions->getDirectory(),
32 1
            $this->fileTransportOptions->getFileNameGenerator()->call($this, $message)
33
        );
34
35 1
        \file_put_contents($fileName, (string)$message);
36 1
    }
37
}
38