SmtpTransportFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * MtMail - e-mail module for Zend Framework
4
 *
5
 * @link      http://github.com/mtymek/MtMail
6
 * @copyright Copyright (c) 2013-2017 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace MtMail\Factory;
11
12
use Interop\Container\ContainerInterface;
13
use Zend\Mail\Transport\Smtp;
14
use Zend\Mail\Transport\SmtpOptions;
15
16
class SmtpTransportFactory
17
{
18 2
    public function __invoke(ContainerInterface $serviceLocator)
19
    {
20 2
        $configuration = $serviceLocator->get('Configuration');
21 2
        $serviceConfig = isset($configuration['mt_mail']['transport_options'])
22 2
            ? $configuration['mt_mail']['transport_options'] : [];
23 2
        $options = new SmtpOptions($serviceConfig);
24 2
        $smtp = new Smtp($options);
25
26 2
        return $smtp;
27
    }
28
}
29