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

SenderServiceFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 4
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\Service\Sender;
14
15
class SenderServiceFactory
16
{
17 2
    public function __invoke(ContainerInterface $serviceLocator)
18
    {
19 2
        $configuration = $serviceLocator->get('Configuration');
20 2
        $transportName = $configuration['mt_mail']['transport'];
21 2
        $service = new Sender($serviceLocator->get($transportName));
22
23 2
        if (isset($configuration['mt_mail']['sender_plugins'])
24 2
            && is_array($configuration['mt_mail']['sender_plugins'])
25 2
        ) {
26 1
            $pluginManager = $serviceLocator->get('MtMail\Service\SenderPluginManager');
27 1
            foreach (array_unique($configuration['mt_mail']['sender_plugins']) as $plugin) {
28 1
                $service->getEventManager()->attachAggregate($pluginManager->get($plugin));
0 ignored issues
show
Deprecated Code introduced by
The method Zend\EventManager\EventM...face::attachAggregate() has been deprecated with message: This method is deprecated with 2.6.0, and will be removed in 3.0.0. See {@link https://github.com/zendframework/zend-eventmanager/blob/develop/doc/book/migration/removed.md} for details.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
29 1
            }
30 1
        }
31
32 2
        return $service;
33
    }
34
}
35