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

LayoutPluginFactory::__invoke()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 10
cts 10
cp 1
rs 9.4285
cc 3
eloc 8
nc 4
nop 1
crap 3
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\Layout;
14
15
class LayoutPluginFactory
16
{
17 3
    public function __invoke(ContainerInterface $serviceLocator)
18
    {
19 3
        if (!method_exists($serviceLocator, 'configure')) {
20 3
            $serviceLocator = $serviceLocator->getServiceLocator();
21 3
        }
22 3
        $config = $serviceLocator->get('Configuration');
23 3
        $plugin = new Layout();
24 3
        if (isset($config['mt_mail']['layout'])) {
25 1
            $plugin->setLayoutTemplate($config['mt_mail']['layout']);
26 1
        }
27
28 3
        return $plugin;
29
    }
30
}
31