@@ -8,24 +8,49 @@ class Hook
88{
99 use ResolvesArgumentTrait;
1010
11- protected $ group ;
12- protected $ operation ;
13- protected $ path ;
14- protected $ status = 200 ;
15- protected $ response = 'application/json ' ;
11+ public $ group ;
12+ public $ operation ;
13+ public $ path ;
14+ public $ status = 200 ;
15+ public $ response = 'application/json ' ;
16+
17+ public function __construct ($ group = null , $ path = null , $ operation = null , $ status = null , $ response = null )
18+ {
19+ if ($ group ) {
20+ $ this ->group = $ group ;
21+ }
22+
23+ if ($ operation ) {
24+ $ this ->operation = $ operation ;
25+ }
26+
27+ if ($ path ) {
28+ $ this ->path = $ path ;
29+ }
30+
31+ if ($ status ) {
32+ $ this ->status = $ status ;
33+ }
34+
35+ if ($ response ) {
36+ $ this ->response = $ response ;
37+ }
38+ }
1639
1740 public function __call ($ method , $ args )
1841 {
1942 if (in_array ($ method , ['group ' , 'path ' , 'operation ' , 'status ' , 'response ' ])) {
20- $ this ->{$ method } = $ args [0 ];
43+ $ hook = $ this ->reCreateSelf ();
44+
45+ $ hook ->{$ method } = $ args [0 ];
2146
2247 if (isset ($ args [1 ])) {
23- if ($ callable = $ this ->resolveArgument ($ args [1 ])) {
24- return $ callable ($ this );
48+ if ($ callable = $ hook ->resolveArgument ($ args [1 ])) {
49+ return $ callable ($ hook );
2550 }
2651 }
2752
28- return $ this ;
53+ return $ hook ;
2954 }
3055
3156 if (in_array ($ method , ['before ' ])) {
@@ -39,6 +64,11 @@ public function __call($method, $args)
3964 }
4065 }
4166
67+ private function reCreateSelf ()
68+ {
69+ return new static ($ this ->group , $ this ->path , $ this ->operation , $ this ->status , $ this ->response );
70+ }
71+
4272 private function buildTransactionName ()
4373 {
4474 return implode (' > ' , [
0 commit comments