IndexControllerFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 1 Features 2
Metric Value
wmc 1
c 4
b 1
f 2
lcom 0
cbo 3
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 1
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the MIT license.
18
 */
19
namespace LearnZF2Themes\Factory\Controller;
20
21
use LearnZF2Themes\Controller\IndexController;
22
use Zend\Mvc\Controller\ControllerManager;
23
24
/**
25
 * @author Stanimir Dimitrov <[email protected]>
26
 */
27
final class IndexControllerFactory
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function __invoke(ControllerManager $controllerManager)
33
    {
34
        $serviceLocator = $controllerManager->getServiceLocator();
35
        $themesConfig = $serviceLocator->get('getThemesFromDir');
36
        $reloadService = $serviceLocator->get('reloadService');
37
        $controller = new IndexController($themesConfig, $reloadService);
0 ignored issues
show
Bug introduced by
It seems like $themesConfig defined by $serviceLocator->get('getThemesFromDir') on line 35 can also be of type object; however, LearnZF2Themes\Controlle...ntroller::__construct() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
38
39
        return $controller;
40
    }
41
}
42