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)
122122 */
123123 public function on (RequestMatcher $ requestMatcher , $ result )
124124 {
125- $ callable = null ;
125+ $ callable = self :: makeCallable ( $ result ) ;
126126
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 makeCallable ($ result )
141+ {
127142 switch (true ) {
128143 case is_callable ($ result ):
129144 $ callable = $ result ;
@@ -144,10 +159,8 @@ public function on(RequestMatcher $requestMatcher, $result)
144159 default :
145160 throw new \InvalidArgumentException ('Result must be either a response, an exception, or a callable ' );
146161 }
147- $ this ->conditionalResults [] = [
148- 'matcher ' => $ requestMatcher ,
149- 'callable ' => $ callable ,
150- ];
162+
163+ return $ callable ;
151164 }
152165
153166 /**
You can’t perform that action at this time.
0 commit comments