diff --git a/src/Core/Concerns/SdkPage.php b/src/Core/Concerns/SdkPage.php index 96e2aa54..0f4d40da 100644 --- a/src/Core/Concerns/SdkPage.php +++ b/src/Core/Concerns/SdkPage.php @@ -57,7 +57,7 @@ public function hasNextPage(): bool public function getNextPage(): static { $next = $this->nextRequest(); - if (!$next) { + if ($next === null) { throw new \RuntimeException( 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.' ); diff --git a/src/Documents/DocumentCreate/Item.php b/src/Documents/DocumentCreate/Item.php index b9928793..784bd44d 100644 --- a/src/Documents/DocumentCreate/Item.php +++ b/src/Documents/DocumentCreate/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentCreateParams/Item.php b/src/Documents/DocumentCreateParams/Item.php index 35efec77..b7fa5f4e 100644 --- a/src/Documents/DocumentCreateParams/Item.php +++ b/src/Documents/DocumentCreateParams/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentNewFromPdfResponse/Item.php b/src/Documents/DocumentNewFromPdfResponse/Item.php index 92344683..c4cab023 100644 --- a/src/Documents/DocumentNewFromPdfResponse/Item.php +++ b/src/Documents/DocumentNewFromPdfResponse/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, ?string $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, ?string $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/Documents/DocumentResponse/Item.php b/src/Documents/DocumentResponse/Item.php index 32fb1ece..ad7d627b 100644 --- a/src/Documents/DocumentResponse/Item.php +++ b/src/Documents/DocumentResponse/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, ?string $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, ?string $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date; diff --git a/src/DocumentsNumberPage.php b/src/DocumentsNumberPage.php index 381a918e..3bf10853 100644 --- a/src/DocumentsNumberPage.php +++ b/src/DocumentsNumberPage.php @@ -111,7 +111,21 @@ public function getItems(): array public function nextRequest(): ?array { $currentPage = $this->page ?? 1; + $pageSize = $this->pageSize ?? 0; + $total = $this->total ?? 0; + + // Check if there are more pages + if ($pageSize === 0 || $total === 0) { + return null; + } + + $totalPages = (int) ceil($total / $pageSize); + if ($currentPage >= $totalPages) { + return null; + } + $nextRequest = $this->request; + $nextRequest['query']['page'] = $currentPage + 1; return [$nextRequest, $this->options]; } diff --git a/src/DocumentsNumberPage/Item.php b/src/DocumentsNumberPage/Item.php index 7ca75a74..bcabfe05 100644 --- a/src/DocumentsNumberPage/Item.php +++ b/src/DocumentsNumberPage/Item.php @@ -8,7 +8,7 @@ use EInvoiceAPI\Core\Contracts\BaseModel; /** - * @phpstan-type ItemShape = array{} + * @phpstan-type ItemShape = array */ final class Item implements BaseModel { diff --git a/src/Validate/ValidateValidateJsonParams/Item.php b/src/Validate/ValidateValidateJsonParams/Item.php index e43054d9..d014e9c6 100644 --- a/src/Validate/ValidateValidateJsonParams/Item.php +++ b/src/Validate/ValidateValidateJsonParams/Item.php @@ -16,7 +16,7 @@ * allowances?: list|null, * amount?: float|string|null, * charges?: list|null, - * date?: null|null, + * date?: \DateTimeInterface|null, * description?: string|null, * productCode?: string|null, * quantity?: float|string|null, @@ -53,9 +53,8 @@ final class Item implements BaseModel #[Api(list: Charge::class, nullable: true, optional: true)] public ?array $charges; - /** @var null|null $date */ #[Api(nullable: true, optional: true)] - public null $date; + public ?\DateTimeInterface $date; /** * The description of the line item. @@ -119,7 +118,7 @@ public static function with( ?array $allowances = null, float|string|null $amount = null, ?array $charges = null, - null $date = null, + ?\DateTimeInterface $date = null, ?string $description = null, ?string $productCode = null, float|string|null $quantity = null, @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self return $obj; } - /** - * @param null|null $date - */ - public function withDate(null $date): self + public function withDate(?\DateTimeInterface $date): self { $obj = clone $this; $obj->date = $date;