1 | <?php |
||
10 | trait Macroable |
||
11 | { |
||
12 | /** |
||
13 | * The registered string macros. |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected static $macros = []; |
||
18 | |||
19 | /** |
||
20 | * Register a custom macro. |
||
21 | * |
||
22 | * @param string $name |
||
23 | * @param object|callable $macro |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | 4 | public static function macro($name, $macro) |
|
31 | |||
32 | /** |
||
33 | * Mix another object into the class. |
||
34 | * |
||
35 | * @param object $mixin |
||
36 | * @return void |
||
37 | */ |
||
38 | 1 | public static function mixin($mixin) |
|
50 | |||
51 | /** |
||
52 | * Checks if macro is registered. |
||
53 | * |
||
54 | * @param string $name |
||
55 | * @return bool |
||
56 | */ |
||
57 | 4 | public static function hasMacro($name) |
|
61 | |||
62 | /** |
||
63 | * Dynamically handle calls to the class. |
||
64 | * |
||
65 | * @param string $method |
||
66 | * @param array $parameters |
||
67 | * @return mixed |
||
68 | * |
||
69 | * @throws \BadMethodCallException |
||
70 | */ |
||
71 | 2 | public static function __callStatic($method, $parameters) |
|
85 | |||
86 | /** |
||
87 | * Dynamically handle calls to the class. |
||
88 | * |
||
89 | * @param string $method |
||
90 | * @param array $parameters |
||
91 | * @return mixed |
||
92 | * |
||
93 | * @throws \BadMethodCallException |
||
94 | */ |
||
95 | 3 | public function __call($method, $parameters) |
|
111 | } |
||
112 |