@@ -75,7 +75,9 @@ public function sendRequest(RequestInterface $request)
75
75
{
76
76
$ this ->requests [] = $ request ;
77
77
78
- foreach ($ this ->conditionalResults as ['matcher ' => $ matcher , 'callable ' => $ callable ]) {
78
+ foreach ($ this ->conditionalResults as $ result ) {
79
+ $ matcher = $ result ['matcher ' ];
80
+ $ callable = $ result ['callable ' ];
79
81
80
82
/**
81
83
* @var RequestMatcher $matcher
@@ -107,28 +109,33 @@ public function sendRequest(RequestInterface $request)
107
109
}
108
110
109
111
/**
110
- * @param RequestMatcher $requestMatcher
112
+ * @param RequestMatcher $requestMatcher
111
113
* @param ResponseInterface|\Exception|callable $result
112
114
*/
113
115
public function on (RequestMatcher $ requestMatcher , $ result )
114
116
{
115
117
$ callable = null ;
118
+
116
119
switch (true ) {
117
120
case is_callable ($ result ):
118
121
$ callable = $ result ;
119
122
break ;
120
123
case $ result instanceof ResponseInterface:
121
- $ callable = function () use ($ result ) { return $ result ; };
124
+ $ callable = function () use ($ result ) {
125
+ return $ result ;
126
+ };
122
127
break ;
123
128
case $ result instanceof \Exception:
124
- $ callable = function () use ($ result ) { throw $ result ; };
129
+ $ callable = function () use ($ result ) {
130
+ throw $ result ;
131
+ };
125
132
break ;
126
133
default :
127
- throw new \InvalidArgumentException (" Result must be either a response, an exception, or a callable " );
134
+ throw new \InvalidArgumentException (' Result must be either a response, an exception, or a callable ' );
128
135
}
129
136
$ this ->conditionalResults [] = [
130
- 'matcher ' => $ requestMatcher ,
131
- 'callable ' => $ callable
137
+ 'matcher ' => $ requestMatcher ,
138
+ 'callable ' => $ callable
132
139
];
133
140
}
134
141
0 commit comments