SenderServiceFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 20
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 4
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 MtMail\Service\Sender;
14
use MtMail\Service\SenderPluginManager;
15
16
class SenderServiceFactory
17
{
18 2
    public function __invoke(ContainerInterface $serviceLocator)
19
    {
20 2
        $configuration = $serviceLocator->get('Configuration');
21 2
        $transportName = $configuration['mt_mail']['transport'];
22 2
        $service = new Sender($serviceLocator->get($transportName));
23
24 2
        if (isset($configuration['mt_mail']['sender_plugins'])
25 2
            && is_array($configuration['mt_mail']['sender_plugins'])
26
        ) {
27 1
            $pluginManager = $serviceLocator->get(SenderPluginManager::class);
28 1
            foreach (array_unique($configuration['mt_mail']['sender_plugins']) as $plugin) {
29 1
                $pluginManager->get($plugin)->attach($service->getEventManager());
30
            }
31
        }
32
33 2
        return $service;
34
    }
35
}
36