| Total Complexity | 10 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 84.21% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class ProxyClass |
||
| 6 | { |
||
| 7 | private $methods = []; |
||
| 8 | |||
| 9 | private $aliases = []; |
||
| 10 | |||
| 11 | 112 | public function _call($method, $param) |
|
| 12 | { |
||
| 13 | 112 | $method = $this->aliases[$method] ?? $method; |
|
| 14 | |||
| 15 | 112 | if (! isset($this->methods[$method])) { |
|
| 16 | throw new \BadMethodCallException($method.' does not exist'); |
||
| 17 | } |
||
| 18 | |||
| 19 | 112 | $condition = $this->methods[$method]; |
|
| 20 | |||
| 21 | 112 | if (is_callable($condition)) { |
|
| 22 | 1 | return call_user_func_array($condition, $param); |
|
| 23 | } |
||
| 24 | |||
| 25 | 111 | [$class, $method] = explode('@', $condition); |
|
| 26 | |||
| 27 | 111 | return call_user_func_array([new $class, $method], $param); |
|
| 28 | } |
||
| 29 | |||
| 30 | 117 | public function define($methodName, $callable) |
|
| 36 | } |
||
| 37 | 117 | } |
|
| 38 | |||
| 39 | 117 | public function alias(string $currentName, string $newName, $override = true) |
|
| 48 | } |
||
| 49 | } |
||
| 50 |