ComposerServiceFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 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\Renderer\RendererInterface;
14
use MtMail\Service\Composer;
15
use MtMail\Service\ComposerPluginManager;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
class ComposerServiceFactory
19
{
20
    /**
21
     * Create service
22
     *
23
     * @param ContainerInterface|ServiceLocatorInterface $serviceLocator
24
     * @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...
25
     * @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...
26
     * @return Composer
27
     */
28 3
    public function __invoke(ContainerInterface $serviceLocator)
29
    {
30 3
        $configuration = $serviceLocator->get('Configuration');
31
        /** @var RendererInterface $renderer */
32 3
        $renderer = $serviceLocator->get($configuration['mt_mail']['renderer']);
33 3
        $service = new Composer($renderer);
34
35 3
        $pluginManager = $serviceLocator->get(ComposerPluginManager::class);
36
37 3
        if (isset($configuration['mt_mail']['composer_plugins'])
38 3
            && is_array($configuration['mt_mail']['composer_plugins'])
39
        ) {
40 2
            foreach (array_unique($configuration['mt_mail']['composer_plugins']) as $plugin) {
41 2
                $pluginManager->get($plugin)->attach($service->getEventManager());
42
            }
43
        }
44
45 3
        return $service;
46
    }
47
}
48