| @@ 75-90 (lines=16) @@ | ||
| 72 | * |
|
| 73 | * @throws \BadMethodCallException |
|
| 74 | */ |
|
| 75 | public static function __callStatic($method, $parameters) |
|
| 76 | { |
|
| 77 | if (! static::hasMacro($method)) { |
|
| 78 | throw new BadMethodCallException(sprintf( |
|
| 79 | 'Method %s::%s does not exist.', static::class, $method |
|
| 80 | )); |
|
| 81 | } |
|
| 82 | ||
| 83 | $macro = static::$macros[$method]; |
|
| 84 | ||
| 85 | if ($macro instanceof Closure) { |
|
| 86 | return call_user_func_array(Closure::bind($macro, null, static::class), $parameters); |
|
| 87 | } |
|
| 88 | ||
| 89 | return $macro(...$parameters); |
|
| 90 | } |
|
| 91 | ||
| 92 | /** |
|
| 93 | * Dynamically handle calls to the class. |
|
| @@ 101-116 (lines=16) @@ | ||
| 98 | * |
|
| 99 | * @throws \BadMethodCallException |
|
| 100 | */ |
|
| 101 | public function __call($method, $parameters) |
|
| 102 | { |
|
| 103 | if (! static::hasMacro($method)) { |
|
| 104 | throw new BadMethodCallException(sprintf( |
|
| 105 | 'Method %s::%s does not exist.', static::class, $method |
|
| 106 | )); |
|
| 107 | } |
|
| 108 | ||
| 109 | $macro = static::$macros[$method]; |
|
| 110 | ||
| 111 | if ($macro instanceof Closure) { |
|
| 112 | return call_user_func_array($macro->bindTo($this, static::class), $parameters); |
|
| 113 | } |
|
| 114 | ||
| 115 | return $macro(...$parameters); |
|
| 116 | } |
|
| 117 | } |
|
| 118 | ||