Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enhancement: Return early
  • Loading branch information
localheinz committed Jun 5, 2019
commit 987c5a0078dde983441f33017c6cf8b33ab78175
12 changes: 3 additions & 9 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,20 @@ private static function makeCallable($result)
{
switch (true) {
case is_callable($result):
$callable = $result;

break;
return $result;
case $result instanceof ResponseInterface:
$callable = function () use ($result) {
return function () use ($result) {
return $result;
};

break;
case $result instanceof \Exception:
$callable = function () use ($result) {
return function () use ($result) {
throw $result;
};

break;
default:
throw new \InvalidArgumentException('Result must be either a response, an exception, or a callable');
}

return $callable;
}

/**
Expand Down