File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,23 @@ public function doSendRequest(RequestInterface $request)
122
122
*/
123
123
public function on (RequestMatcher $ requestMatcher , $ result )
124
124
{
125
- $ callable = null ;
125
+ $ callable = self :: ensureCallable ( $ result ) ;
126
126
127
+ $ this ->conditionalResults [] = [
128
+ 'matcher ' => $ requestMatcher ,
129
+ 'callable ' => $ callable ,
130
+ ];
131
+ }
132
+
133
+ /**
134
+ * @param ResponseInterface|Exception|ClientExceptionInterface|callable $result
135
+ *
136
+ * @throws \InvalidArgumentException
137
+ *
138
+ * @return callable
139
+ */
140
+ private static function ensureCallable ($ result )
141
+ {
127
142
switch (true ) {
128
143
case is_callable ($ result ):
129
144
$ callable = $ result ;
@@ -144,10 +159,8 @@ public function on(RequestMatcher $requestMatcher, $result)
144
159
default :
145
160
throw new \InvalidArgumentException ('Result must be either a response, an exception, or a callable ' );
146
161
}
147
- $ this ->conditionalResults [] = [
148
- 'matcher ' => $ requestMatcher ,
149
- 'callable ' => $ callable ,
150
- ];
162
+
163
+ return $ callable ;
151
164
}
152
165
153
166
/**
You can’t perform that action at this time.
0 commit comments