From dd20c633788e74bea2e5722baf0fcd598bf964eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dezs=C5=91=20BICZ=C3=93?= Date: Fri, 24 May 2024 19:30:09 +0200 Subject: [PATCH] Fix handling of empty response (#364) Closes https://github.com/apigee/apigee-client-php/issues/363 Co-authored-by: Shishir <75600200+shishir-intelli@users.noreply.github.com> Co-authored-by: Kedar Khaire --- src/Controller/NonPaginatedEntityListingControllerTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Controller/NonPaginatedEntityListingControllerTrait.php b/src/Controller/NonPaginatedEntityListingControllerTrait.php index 807302b5..1a14f446 100644 --- a/src/Controller/NonPaginatedEntityListingControllerTrait.php +++ b/src/Controller/NonPaginatedEntityListingControllerTrait.php @@ -23,7 +23,7 @@ /** * Trait NonPaginatedEntityListingControllerTrait. * - * @see \Apigee\Edge\Controller\NonPaginatedEntityListingControllerInterface + * @see NonPaginatedEntityListingControllerInterface */ trait NonPaginatedEntityListingControllerTrait { @@ -43,6 +43,9 @@ public function getEntities(): array $uri = $this->getBaseEndpointUri()->withQuery(http_build_query($query_params)); $response = $this->getClient()->get($uri); $responseArray = $this->responseToArray($response); + if ([] === $responseArray) { + return []; + } // Ignore entity type key from response, ex.: apiProduct. $responseArray = reset($responseArray);