Skip to content

Commit

Permalink
Accept multiple return types
Browse files Browse the repository at this point in the history
  • Loading branch information
madmages committed Sep 12, 2022
1 parent 487b933 commit 28f9f9e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/TypedClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ abstract public function _apiCall(string $method, array $parameters): string;
*/
private function _requestWithMap(string $method, array $requestParams, array $returnType)
{
if (count($returnType) > 1) {
throw new TelegramException('More than one return type is not implemented');
}

$responseJson = $this->_apiCall($method, $this->_prepareRequest($requestParams));
if (empty($returnType)) {
try {
Expand All @@ -39,7 +35,7 @@ private function _requestWithMap(string $method, array $requestParams, array $re
}
}

return Serializer::deserialize($responseJson, $returnType[0]);
return Serializer::deserialize($responseJson, implode('|', $returnType));
}

/**
Expand Down

0 comments on commit 28f9f9e

Please sign in to comment.