ColumnsFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 93.1 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 3
c 3
b 0
f 2
lcom 0
cbo 2
dl 27
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 9 9 2
A createService() 3 4 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
namespace ZfcDatagrid\Renderer\JqGrid\View\Helper;
4
5
use Interop\Container\ContainerInterface;
6
use Zend\ServiceManager\AbstractPluginManager;
7
use Zend\ServiceManager\FactoryInterface;
8
use Zend\ServiceManager\ServiceLocatorInterface;
9
10 View Code Duplication
class ColumnsFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
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...
11
{
12
    /**
13
     * @param ContainerInterface $container
14
     * @param string             $requestedName
15
     * @param array|null         $options
16
     *
17
     * @return Columns
18
     */
19
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
20
    {
21
        $tableRow = new Columns();
22
        if ($container->has('translator')) {
23
            $tableRow->setTranslator($container->get('translator'));
24
        }
25
26
        return $tableRow;
27
    }
28
29
    /**
30
     * @param ServiceLocatorInterface|AbstractPluginManager $serviceLocator
31
     *
32
     * @return Columns
33
     */
34
    public function createService(ServiceLocatorInterface $serviceLocator)
35
    {
36
        return $this($serviceLocator->getServiceLocator(), Columns::class);
37
    }
38
}
39