Completed
Pull Request — master (#165)
by Paul
03:21
created

ControllerNameParserFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 6 1
1
<?php
2
/**
3
 * This file is part of the PPI Framework.
4
 *
5
 * @copyright   Copyright (c) 2012 Paul Dragoonis <[email protected]>
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 *
8
 * @link        http://www.ppi.io
9
 */
10
11
namespace PPI\Framework\ServiceManager\Factory;
12
13
use PPI\Framework\Module\Controller\ControllerNameParser;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
/**
18
 * ControllerNameParserFactory.
19
 *
20
 * @author     Vítor Brandão <[email protected]>
21
 */
22
class ControllerNameParserFactory implements FactoryInterface
23
{
24
    /**
25
     * Create and return a ControllerNameParser instance.
26
     *
27
     * @param ServiceLocatorInterface $serviceLocator
28
     *
29
     * @return \PPI\Framework\Module\Controller\ControllerNameParser
30
     */
31
    public function createService(ServiceLocatorInterface $serviceLocator)
32
    {
33
        $moduleManager = $serviceLocator->get('ModuleManager');
34
35
        return new ControllerNameParser($moduleManager);
0 ignored issues
show
Documentation introduced by
$moduleManager is of type object|array, but the function expects a object<Zend\ModuleManager\ModuleManagerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
    }
37
}
38