Skip to content

Commit 1ad4c09

Browse files
committed
Enhancement: Use if instead of switch
1 parent 987c5a0 commit 1ad4c09

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/Client.php

+15-14
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,23 @@ public function on(RequestMatcher $requestMatcher, $result)
139139
*/
140140
private static function makeCallable($result)
141141
{
142-
switch (true) {
143-
case is_callable($result):
142+
if (is_callable($result)) {
143+
return $result;
144+
}
145+
146+
if ($result instanceof ResponseInterface) {
147+
return function () use ($result) {
144148
return $result;
145-
case $result instanceof ResponseInterface:
146-
return function () use ($result) {
147-
return $result;
148-
};
149-
150-
break;
151-
case $result instanceof \Exception:
152-
return function () use ($result) {
153-
throw $result;
154-
};
155-
default:
156-
throw new \InvalidArgumentException('Result must be either a response, an exception, or a callable');
149+
};
157150
}
151+
152+
if ($result instanceof \Exception) {
153+
return function () use ($result) {
154+
throw $result;
155+
};
156+
}
157+
158+
throw new \InvalidArgumentException('Result must be either a response, an exception, or a callable');
158159
}
159160

160161
/**

0 commit comments

Comments
 (0)