From f16dd9a039aaa8db48dda8b720fb39377b2c7d9a Mon Sep 17 00:00:00 2001 From: AN0R31 Date: Tue, 2 Jul 2024 16:45:42 +0300 Subject: [PATCH] If no results are returned from the CIF search, $results will be null, but calling Client->first() method will try to access $results[0], which will throw the given error. By checking if any results are found, the issue is safely avoided. --- src/Client.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index d7be436..cccdca9 100644 --- a/src/Client.php +++ b/src/Client.php @@ -64,14 +64,14 @@ public function get(): array } /** - * @return Company + * @return Company|null * @throws Exceptions\LimitExceeded * @throws Exceptions\RequestFailed * @throws Exceptions\ResponseFailed */ - public function first(): Company + public function first(): ?Company { $results = Http::call($this->cifs); - return new Company(new Parser($results[0])); + return $results[0] ? new Company(new Parser($results[0])) : null; } }