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