Total Complexity | 7 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Coverage | 83.33% |
Changes | 0 |
1 | <?php |
||
5 | class ConditionsFacade |
||
6 | { |
||
7 | private $methods = []; |
||
8 | |||
9 | 100 | public function _call($method, $param) |
|
10 | { |
||
11 | 100 | if (! isset($this->methods[$method])) { |
|
12 | throw new \BadMethodCallException($method.' does not exists as a Heyman condition'); |
||
13 | } |
||
14 | 100 | $condition = $this->methods[$method]; |
|
15 | |||
16 | 100 | if (is_callable($condition)) { |
|
17 | 1 | return $condition(...$param); |
|
18 | } |
||
19 | |||
20 | 99 | list($class, $method) = explode('@', $condition); |
|
21 | |||
22 | 99 | return call_user_func_array([new $class, $method], $param); |
|
23 | } |
||
24 | |||
25 | 110 | public function define($methodName, $callable) |
|
31 | } |
||
32 | 110 | } |
|
34 |