Passed
Push — release ( 33e265...632ae2 )
by Mateusz
14:41 queued 11:19
created

DefaultHeadersPluginFactory::__invoke()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 4
nop 1
crap 3.0175
1
<?php
2
/**
3
 * MtMail - e-mail module for Zend Framework 2
4
 *
5
 * @link      http://github.com/mtymek/MtMail
6
 * @copyright Copyright (c) 2013-2014 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace MtMail\Factory;
11
12
use Interop\Container\ContainerInterface;
13
use MtMail\ComposerPlugin\DefaultHeaders;
14
15
class DefaultHeadersPluginFactory
16
{
17 4
    public function __invoke(ContainerInterface $serviceLocator)
18
    {
19 4
        if (!method_exists($serviceLocator, 'configure')) {
20
            $serviceLocator = $serviceLocator->getServiceLocator();
21
        }
22 4
        $config = $serviceLocator->get('Configuration');
23 4
        $plugin = new DefaultHeaders();
24 4
        if (isset($config['mt_mail']['default_headers'])) {
25 4
            $plugin->setHeaders($config['mt_mail']['default_headers']);
26
        }
27
28 4
        return $plugin;
29
    }
30
}
31