SendMailTransport::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 2
rs 10
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