Passed
Pull Request — develop (#11)
by Misha
03:05
created

PlainSmtpTransportFactory   A

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