| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Locator |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var LocatorProxyFactory |
||
| 12 | */ |
||
| 13 | private $factory; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var LocatorParameterInterface |
||
| 17 | */ |
||
| 18 | private $parameter; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var LocatorProxyInterface[] |
||
| 22 | */ |
||
| 23 | private $proxies; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Locator constructor. |
||
| 27 | * @param LocatorProxyFactory $factory |
||
| 28 | */ |
||
| 29 | 3 | public function __construct(LocatorProxyFactory $factory, LocatorParameterInterface $parameter = null) |
|
| 30 | { |
||
| 31 | 3 | $this->factory = $factory; |
|
| 32 | 3 | $this->parameter = $parameter ?? new LocatorParameter(); |
|
| 33 | 3 | $this->proxies = []; |
|
| 34 | 3 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $moduleName |
||
| 38 | * @return LocatorProxyInterface |
||
| 39 | * @throws Proxy\NotFoundException |
||
| 40 | */ |
||
| 41 | 4 | public function locate(string $moduleName) : LocatorProxyInterface |
|
| 42 | { |
||
| 43 | 4 | if(!isset($this->proxies[$moduleName])){ |
|
| 44 | 3 | $this->proxies[$moduleName] = $this->factory->create($moduleName, $this); |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | return $this->proxies[$moduleName]; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param string $name |
||
| 52 | * @param array $arguments |
||
| 53 | * @return LocatorProxyInterface |
||
| 54 | * @throws Proxy\NotFoundException |
||
| 55 | */ |
||
| 56 | 2 | public function __call(string $name, array $arguments) |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return LocatorParameterInterface |
||
| 63 | */ |
||
| 64 | 1 | public function parameter(): LocatorParameterInterface |
|
| 67 | } |
||
| 68 | } |