From 5b5764939df9cfd11b0d6ce024707c1a5aac4fc2 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 18 Feb 2024 03:55:40 +0200 Subject: [PATCH] implement getError method --- src/Client.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Client.php b/src/Client.php index defb780..17badc0 100644 --- a/src/Client.php +++ b/src/Client.php @@ -85,24 +85,23 @@ class Client bool $json = true ): ?array { - $response = curl_exec( - $this->_curl - ); + if ($response = curl_exec($this->_curl)) + { + return $json ? json_decode($response, true) : $response; + } + + return null; + } - $errorNumber = curl_errno( + public function getError(?int &$code = null): mixed + { + $code = curl_errno( $this->_curl ); - $errorText = curl_error( + return curl_error( $this->_curl ); - - if ($response) - { - return $json ? json_decode($response, true) : $response; - } - - return null; } public function getBlockCount(): ?int