Completed
Pull Request — master (#29)
by Mateusz
37:30 queued 34:33
created

LayoutPluginFactory::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 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
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\Layout;
14
15
class LayoutPluginFactory
16
{
17
    public function __invoke(ContainerInterface $serviceLocator)
18
    {
19
        if (!method_exists($serviceLocator, 'configure')) {
20
            $serviceLocator = $serviceLocator->getServiceLocator();
21
        }
22
        $config = $serviceLocator->get('Configuration');
23
        $plugin = new Layout();
24
        if (isset($config['mt_mail']['layout'])) {
25 1
            $plugin->setLayoutTemplate($config['mt_mail']['layout']);
26
        }
27 1
28 1
        return $plugin;
29 1
    }
30
}
31