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