-
Notifications
You must be signed in to change notification settings - Fork 4
Added paginated response support for listing work items #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thijskok
merged 8 commits into
testmonitor:master
from
thijskok:added-paginated-response-support
Apr 22, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5db1a6c
Added paginated response support for work items
thijskok 480e596
StyleCI fix
thijskok 9a02314
StyleCI fix
thijskok f3c573e
Improved test coverage
thijskok 23a6ee9
Added more examples
thijskok ab12786
Enhance WorkItemsTest for pagination
thijskok b9edc4f
Add note about total() method limit in README
thijskok 2e8ffe0
Apply suggestion from @Copilot
thijskok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| <?php | ||
|
|
||
| namespace TestMonitor\DevOps\Responses; | ||
|
|
||
| class LengthAwarePaginatedResponse | ||
| { | ||
| /** | ||
| * The items being paginated. | ||
| * | ||
| * @var array | ||
| */ | ||
| protected array $items; | ||
|
|
||
| /** | ||
| * The total number of items being paginated. | ||
| * | ||
| * @var int | ||
| */ | ||
| protected int $total; | ||
|
|
||
| /** | ||
| * The number of items shown per page. | ||
| * | ||
| * @var int | ||
| */ | ||
| protected int $perPage; | ||
|
|
||
| /** | ||
| * The current item offset. | ||
| * | ||
| * @var int | ||
| */ | ||
| protected int $offset; | ||
|
|
||
| /** | ||
| * Create a new paginated response instance. | ||
| * | ||
| * @param array $items | ||
| * @param int $total | ||
| * @param int $perPage | ||
| * @param int $offset | ||
| */ | ||
| public function __construct(array $items, int $total, int $perPage, int $offset = 0) | ||
| { | ||
| $this->items = $items; | ||
| $this->total = $total; | ||
| $this->perPage = $perPage; | ||
| $this->offset = $offset; | ||
| } | ||
|
|
||
| /** | ||
| * Get the items being paginated. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function items(): array | ||
| { | ||
| return $this->items; | ||
| } | ||
|
|
||
| /** | ||
| * Get the total number of items being paginated. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function total(): int | ||
| { | ||
| return $this->total; | ||
| } | ||
|
|
||
| /** | ||
| * Get the number of items shown per page. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function perPage(): int | ||
| { | ||
| return $this->perPage; | ||
| } | ||
|
|
||
| /** | ||
| * Get the current item offset. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function offset(): int | ||
| { | ||
| return $this->offset; | ||
| } | ||
|
|
||
| /** | ||
| * Determine the current page. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function currentPage(): int | ||
| { | ||
| if ($this->offset === 0 || $this->perPage === 0) { | ||
| return 1; | ||
| } | ||
|
|
||
| return (int) floor($this->offset / $this->perPage) + 1; | ||
| } | ||
|
thijskok marked this conversation as resolved.
thijskok marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.