LocatorProxyFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 31
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 9 3
1
<?php
2
3
namespace PHPassword\Locator\Proxy;
4
5
use PHPassword\Locator\Facade\EmptyFacade;
6
use PHPassword\Locator\Factory\EmptyFactory;
7
use PHPassword\Locator\Locator;
8
9
class LocatorProxyFactory
10
{
11
    /**
12
     * @var \ArrayObject
13
     */
14
    private $searchableNamespaces;
15
16
    /**
17
     * LocatorProxyFactory constructor.
18
     * @param \ArrayObject $searchableNamespaces
19
     */
20 3
    public function __construct(\ArrayObject $searchableNamespaces)
21
    {
22 3
        $this->searchableNamespaces = $searchableNamespaces;
23 3
    }
24
25
    /**
26
     * @param string $moduleName
27
     * @param Locator $locator
28
     * @return LocatorProxyInterface
29
     * @throws NotFoundException
30
     */
31 5
    public function create(string $moduleName, Locator $locator) : LocatorProxyInterface
32
    {
33 5
        $proxy = new LocatorProxy($this->searchableNamespaces, $moduleName, $locator);
34 5
        if(get_class($proxy->factory()) === EmptyFactory::class
35 5
            && get_class($proxy->facade()) === EmptyFacade::class){
36 3
            throw new NotFoundException(sprintf('Module %s was not found. You need at least a factory or a facade', $moduleName));
37
        }
38
39 2
        return $proxy;
40
    }
41
}