File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,14 @@ public function __construct($target)
2525 /**
2626 * Dynamically pass method calls to the target.
2727 *
28- * @param callable $callback
28+ * @param string $method
29+ * @param array $parameters
2930 * @return mixed
3031 */
31- public function __invoke ( $ callback )
32+ public function __call ( $ method , $ parameters )
3233 {
33- return $ callback ($ this ->target );
34+ $ this ->target ->{$ method }(...$ parameters );
35+
36+ return $ this ->target ;
3437 }
3538}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Farzai \Support \HigherOrderTapProxy ;
4+
5+ it ('calls the method on the target ' , function () {
6+ $ target = new class {
7+ public $ called = false ;
8+
9+ public function foo ()
10+ {
11+ $ this ->called = true ;
12+ }
13+ };
14+
15+ $ proxy = new HigherOrderTapProxy ($ target );
16+
17+ $ proxy ->foo ();
18+
19+ expect ($ target ->called )->toBeTrue ();
20+ });
You can’t perform that action at this time.
0 commit comments