Passed
Push — v3_compat ( af37b8...c7ae23 )
by Mateusz
03:38
created

DefaultHeadersPluginFactory::createService()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2
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 4
            $serviceLocator = $serviceLocator->getServiceLocator();
21 4
        }
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 4
        }
27
28 4
        return $plugin;
29
    }
30
}
31