Total Complexity | 3 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | class ServiceLocator implements ServiceLocatorInterface |
||
18 | { |
||
19 | protected $instances = []; |
||
20 | |||
21 | /** |
||
22 | * @param $class |
||
23 | * @param array $arguments |
||
24 | * |
||
25 | * @return mixed |
||
26 | * Low level instantiation to keep me save from tightly coupling |
||
27 | */ |
||
28 | public function create($class, array $arguments = []) |
||
29 | { |
||
30 | $classHash = hash('md5', $class . implode("", array_values($arguments))); |
||
31 | if (!isset($this->instances[$classHash])) { |
||
32 | $this->instances[$classHash] = new $class($arguments); |
||
33 | } |
||
34 | |||
35 | return $this->instances[$classHash]; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @inheritDoc |
||
40 | */ |
||
41 | public function get($class) |
||
44 | } |
||
45 | } |
||
46 |