Completed
Push — master ( 897ca6...2f8287 )
by Dmitriy
06:01
created

createServiceWithName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 10
loc 10
rs 9.4286
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace T4web\DomainModule\Infrastructure;
4
5
use Zend\ServiceManager\AbstractFactoryInterface;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
use T4webInfrastructure\CriteriaFactory;
8
9
/**
10
 * Create Service by template:
11
 *   MODULE-NAME\ENTITY-NAME\Infrastructure\CriteriaFactory
12
 *
13
 * @package T4web\DomainModule\Infrastructure
14
 */
15 View Code Duplication
class CriteriaFactoryAbstractFactory implements AbstractFactoryInterface
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...
16
{
17
    public function canCreateServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName)
18
    {
19
        return substr($requestedName, -strlen('Infrastructure\CriteriaFactory')) == 'Infrastructure\CriteriaFactory';
20
    }
21
22
    public function createServiceWithName(ServiceLocatorInterface $serviceManager, $name, $requestedName)
23
    {
24
        $namespace = strstr($requestedName, 'Infrastructure\CriteriaFactory', true);
25
26
        list($moduleName, $entityName) = explode('\\', $namespace);
27
28
        return new CriteriaFactory(
29
            $serviceManager->get("$moduleName\\$entityName\\Infrastructure\\Config")
0 ignored issues
show
Unused Code introduced by
The call to CriteriaFactory::__construct() has too many arguments starting with $serviceManager->get("{$...nfrastructure\\Config").

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...
30
        );
31
    }
32
}