Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
.idea
composer.phar
composer.lock
vendor/
vendor/
8 changes: 4 additions & 4 deletions src/Picqer/Carriers/SendCloud/Query/FindAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function all($params = [], ?int $maxPages = 1): array
while (true) {
$result = $this->connection()->get($this->url, $params);

$allRecords = array_merge($allRecords, $this->collectionFromResult($result));
$allRecords[] = $this->collectionFromResult($result);

if (! empty($result['next'])) {
// Get the querystring params from the next url, so we can retrieve the next page
$params = parse_url($result['next'], PHP_URL_QUERY);
$params = \parse_url($result['next'], PHP_URL_QUERY);
} else {
// If no next page is found, all records are complete
break;
Expand All @@ -34,12 +34,12 @@ public function all($params = [], ?int $maxPages = 1): array
$pages++;

// If max pages is set and reached, also stop the loop
if (! is_null($maxPages) && $pages >= $maxPages) {
if (null !== $maxPages && $pages >= $maxPages) {
break;
}
}

return $allRecords;
return \array_merge(...$allRecords);
}

public function collectionFromResult($result): array
Expand Down