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

ControllerNameParserFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 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