Completed
Pull Request — master (#152)
by Paul
03:25
created

RouterFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 16
Bugs 1 Features 0
Metric Value
wmc 2
c 16
b 1
f 0
lcom 0
cbo 1
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 9 2
1
<?php
2
/**
3
 * This file is part of the PPI Framework.
4
 *
5
 * @copyright   Copyright (c) 2011-2015 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
14
use Symfony\Component\Routing\RouteCollection as SymfonyRouteCollection;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
/**
19
 * Router Factory.
20
 *
21
 * @author     Paul Dragoonis <[email protected]>
22
 * @author     Vítor Brandão <[email protected]>
23
 */
24
class RouterFactory implements FactoryInterface
25
{
26
    /**
27
     * @todo - move this to a separate method() - consider how to inject custom-defined arbitrary chain router entries
28
     *
29
     * @param ServiceLocatorInterface $serviceLocator
30
     *
31
     * @throws \Exception
32
     *
33
     * @return ChainRouter
34
     */
35
    public function createService(ServiceLocatorInterface $serviceLocator)
36
    {
37
38
        $routerOptions   = array();
0 ignored issues
show
Unused Code introduced by
$routerOptions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
        $logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;
40
        $chainRouter = new ChainRouter($logger);
41
42
        return $chainRouter;
43
    }
44
}
45