1 | <?php |
||
16 | trait InjectMethods |
||
17 | { |
||
18 | /** |
||
19 | * @var \Closure[] |
||
20 | */ |
||
21 | protected $injectedMethods; |
||
22 | |||
23 | /** |
||
24 | * InjectMethods constructor. |
||
25 | * |
||
26 | * @param \Closure[] $injectedMethods |
||
27 | */ |
||
28 | 5 | public function __construct(array $injectedMethods = []) |
|
34 | |||
35 | /** |
||
36 | * Inject method |
||
37 | * |
||
38 | * @param string $name |
||
39 | * @param \Closure $closure |
||
40 | * @return $this |
||
41 | */ |
||
42 | 4 | public function injectMethod(string $name, \Closure $closure) |
|
51 | |||
52 | /** |
||
53 | * Removing injected method |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @return $this |
||
57 | */ |
||
58 | 1 | public function removeMethod(string $name) |
|
64 | |||
65 | /** |
||
66 | * Calling injected method |
||
67 | * |
||
68 | * @param $name |
||
69 | * @param $arguments |
||
70 | * @return mixed |
||
71 | * @throws MethodNotFoundException |
||
72 | */ |
||
73 | 4 | public function __call($name, $arguments) |
|
81 | |||
82 | /** |
||
83 | * JS-style settings methods |
||
84 | * |
||
85 | * @param $name |
||
86 | * @param $value |
||
87 | * @return bool |
||
88 | */ |
||
89 | 3 | public function __set($name, $value) |
|
99 | |||
100 | /** |
||
101 | * @param $name |
||
102 | * @return \Closure|mixed |
||
103 | */ |
||
104 | 1 | public function __get($name) |
|
112 | } |