Completed
Push — develop ( f2612d...39673b )
by
unknown
15:00 queued 07:47
created

ManageControllerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
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 21
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 11 11 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\ManageController;
13
use Core\Repository\RepositoryService;
14
use Zend\Mvc\Controller\ControllerManager;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18 View Code Duplication
class ManageControllerFactory 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
     * Injects all needed services into the ManageController
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     *
25
     * @return ManageController
26
     */
27
    public function createService(ServiceLocatorInterface $serviceLocator)
28
    {
29
        /* @var ControllerManager $serviceLocator */
30
        $serviceLocator = $serviceLocator->getServiceLocator();
31
        $auth = $serviceLocator->get('AuthenticationService');
32
        /* @var RepositoryService     $repositoryService */
33
        $repositoryService =    $serviceLocator->get('repositories');
34
35
        $translator =    $serviceLocator->get('translator');
36
        return new ManageController($auth, $repositoryService, $translator);
0 ignored issues
show
Documentation introduced by
$auth is of type object|array, but the function expects a object<Auth\AuthenticationService>.

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...
Documentation introduced by
$translator is of type object|array, but the function expects a object<Zend\Mvc\I18n\Translator>.

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...
37
    }
38
}