PlainSmtpTransportFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
ccs 8
cts 8
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSupportedSchemes() 0 3 1
A create() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FH\Bundle\MailerBundle\Transport\Smtp;
6
7
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
8
use Symfony\Component\Mailer\Transport\Dsn;
9
use Symfony\Component\Mailer\Transport\Smtp\SmtpTransport;
10
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
11
use Symfony\Component\Mailer\Transport\TransportInterface;
12
13
final class PlainSmtpTransportFactory extends AbstractTransportFactory
14
{
15
    /**
16
     * @return string[]
17
     */
18 2
    protected function getSupportedSchemes(): array
19
    {
20 2
        return ['plainsmtp'];
21
    }
22
23
    /**
24
     * @return SmtpTransport
25
     */
26 2
    public function create(Dsn $dsn): TransportInterface
27
    {
28 2
        $stream = new SocketStream();
29 2
        $stream->disableTls();
30 2
        $stream->setPort((int) $dsn->getPort(25));
31 2
        $stream->setHost($dsn->getHost());
32
33 2
        return new SmtpTransport($stream, $this->dispatcher, $this->logger);
34
    }
35
}
36