| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public static function create(\ReflectionClass $type): object |
||
| 23 | { |
||
| 24 | $interface = $type->getName(); |
||
| 25 | |||
| 26 | if (\array_key_exists($interface, self::$cache)) { |
||
| 27 | return self::$cache[$interface]; |
||
| 28 | } |
||
| 29 | |||
| 30 | $className = "{$type->getNamespaceName()}\\{$type->getShortName()} SCOPED PROXY"; |
||
| 31 | |||
| 32 | try { |
||
| 33 | $classString = ProxyClassRenderer::renderClass($type, $className); |
||
| 34 | |||
| 35 | eval($classString); |
||
| 36 | } catch (\Throwable $e) { |
||
| 37 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
||
| 38 | } |
||
| 39 | $instance = new $className(); |
||
| 40 | $instance::$__container_proxy_alias = $interface; |
||
| 41 | |||
| 42 | return self::$cache[$interface] = $instance; |
||
| 43 | } |
||
| 45 |