Skip to content

Commit

Permalink
Merge pull request #14 from justbetter/feature/lazy
Browse files Browse the repository at this point in the history
The lazy method accepts a pageSize and is always casted to an integer
  • Loading branch information
VincentBean authored Mar 24, 2023
2 parents f3b1643 + ac7789e commit 63412bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public function firstOrCreate(array $attributes = [], array $values = []): BaseR
return $this->newResourceInstance()->create($data);
}

public function lazy(): LazyCollection
public function lazy(?int $pageSize = null): LazyCollection
{
return LazyCollection::make(function (): Generator {
$pageSize = config('dynamics.connections.'.$this->connection.'.page_size');
return LazyCollection::make(function () use ($pageSize): Generator {
$pageSize ??= (int) config('dynamics.connections.'.$this->connection.'.page_size');
$page = 0;

$hasNext = true;
Expand Down
4 changes: 4 additions & 0 deletions tests/OData/BaseResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ protected function setUp(): void

config()->set('dynamics.connections.::default::', [
'base_url' => '::base_url::',
'version' => 'ODataV4',
'company' => '::company::',
'username' => '::username::',
'password' => '::password::',
'auth' => '::auth::',
'page_size' => 1000,
'options' => [
'connect_timeout' => 5,
],
]);

config()->set('dynamics.connections.::other-connection::', [
'base_url' => '::base_url::',
'version' => 'ODataV4',
'company' => '::company::',
'username' => '::username::',
'password' => '::password::',
'auth' => '::auth::',
'page_size' => 1000,
'options' => [
'connect_timeout' => 5,
],
Expand Down

0 comments on commit 63412bb

Please sign in to comment.