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

ComposerServiceFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 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\Renderer\RendererInterface;
14
use MtMail\Service\Composer;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
class ComposerServiceFactory
18
{
19
    /**
20
     * Create service
21
     *
22
     * @param ContainerInterface|ServiceLocatorInterface $serviceLocator
23
     * @param string $requestedName
0 ignored issues
show
Bug introduced by
There is no parameter named $requestedName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     * @param array $options
0 ignored issues
show
Bug introduced by
There is no parameter named $options. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
25
     * @return Composer
26
     */
27 3
    public function __invoke(ContainerInterface $serviceLocator)
28
    {
29 3
        $configuration = $serviceLocator->get('Configuration');
30
        /** @var RendererInterface $renderer */
31 3
        $renderer = $serviceLocator->get($configuration['mt_mail']['renderer']);
32 3
        $service = new Composer($renderer);
33
34 3
        $pluginManager = $serviceLocator->get('MtMail\Service\ComposerPluginManager');
35
36 3
        if (isset($configuration['mt_mail']['composer_plugins'])
37 3
            && is_array($configuration['mt_mail']['composer_plugins'])
38 3
        ) {
39 2
            foreach (array_unique($configuration['mt_mail']['composer_plugins']) as $plugin) {
40 2
                $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...
41 2
            }
42 2
        }
43
44 3
        return $service;
45
    }
46
}
47