FileTransport   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A send() 0 10 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