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

SenderServiceFactory::__invoke()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
ccs 13
cts 13
cp 1
rs 9.2
cc 4
eloc 10
nc 2
nop 1
crap 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