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