SendMailTransport   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace Da\Mailer\Transport;
4
5
use Symfony\Component\Mailer\Transport\Dsn;
6
7
class SendMailTransport implements TransportInterface
8
{
9
    /**
10
     * @var \Symfony\Component\Mailer\Transport\SendmailTransport
11
     */
12
    private $instance;
13
/**
14
     * @var string
15
     */
16
    private string $dsn;
17
    public function __construct(string $dsn)
18
    {
19
        $this->dsn = $dsn;
20
    }
21 3
22
    /**
23 3
     * Returns the Swift_SendmailTransport instance.
24 3
     *
25
     * @return \Symfony\Component\Mailer\Transport\SendmailTransport instance
26
     */
27
    public function getInstance(): \Symfony\Component\Mailer\Transport\SendmailTransport
28
    {
29
        if ($this->instance === null) {
30
            $sendMailFactory = new \Symfony\Component\Mailer\Transport\SendmailTransportFactory();
31 3
            $this->instance = $sendMailFactory->create(Dsn::fromString($this->dsn));
32
        }
33 3
34 3
        return $this->instance;
35 3
    }
36
}
37