Completed
Push — develop ( 7b602d...d209d7 )
by
unknown
16:15 queued 08:21
created

IndexControllerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
7
 * @license       MIT
8
 */
9
10
namespace Jobs\Factory\Controller;
11
12
use Jobs\Controller\IndexController;
13
use Jobs\Repository;
14
use Zend\Mvc\Controller\ControllerManager;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18 View Code Duplication
class IndexControllerFactory implements FactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
21
    /**
22
     * Injects all needed services into the IndexController
23
     *
24
     * @param ServiceLocatorInterface $serviceLocator
25
     *
26
     * @return JobboardController
0 ignored issues
show
Documentation introduced by
Should the return type not be IndexController?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
27
     */
28
    public function createService(ServiceLocatorInterface $serviceLocator)
29
    {
30
        /** @var ControllerManager $serviceLocator */
31
        $serviceLocator = $serviceLocator->getServiceLocator();
32
33
        $searchForm = $serviceLocator->get('forms')->get('Jobs/ListFilter', /* useAcl */ true);
34
35
        /**
36
         * @var $jobRepository Repository\Job
37
         */
38
        $jobRepository = $serviceLocator->get('repositories')->get('Jobs/Job');
39
40
        return new IndexController($jobRepository, $searchForm);
0 ignored issues
show
Unused Code introduced by
The call to IndexController::__construct() has too many arguments starting with $jobRepository.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
41
    }
42
}
43