Skip to content

Commit 3efab13

Browse files
committed
docs: Update metadata documentation to clarify key ordering in JSON:API responses.
1 parent b2fbf42 commit 3efab13

6 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/Cursor/Page.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public function hasNext(): bool
127127
/**
128128
* Returns the cursor page as the JSON:API meta contents.
129129
*
130-
* @return array<string, int|bool> The meta contents keyed in length-ascending order.
130+
* @return array<string, int|bool> The meta contents, counts and sizes first, then the boolean
131+
* flags, each by ascending key-name length.
131132
*/
132133
public function metadata(): array
133134
{

src/Offset/Page.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public function hasNext(): bool
149149
/**
150150
* Returns the page as the JSON:API meta contents.
151151
*
152-
* @return array<string, int|bool> The meta contents keyed in length-ascending order.
152+
* @return array<string, int|bool> The meta contents, counts and sizes first, then the boolean
153+
* flags, each by ascending key-name length.
153154
*/
154155
public function metadata(): array
155156
{

src/Offset/Slice.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public function hasNext(): bool
117117
/**
118118
* Returns the slice as the JSON:API meta contents.
119119
*
120-
* @return array<string, int|bool> The meta contents keyed in length-ascending order.
120+
* @return array<string, int|bool> The meta contents, counts and sizes first, then the boolean
121+
* flags, each by ascending key-name length.
121122
*/
122123
public function metadata(): array
123124
{

tests/Unit/Cursor/PageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testNavigationWhenNoExtraElementThenHasNoNextPage(): void
4949
/** @And the navigation lists no target */
5050
self::assertCount(0, $page->navigation()->targets()->toArray());
5151

52-
/** @And the metadata reports no next page in length-ascending key order */
52+
/** @And the metadata reports no next page in grouped key order (counts and sizes, then the boolean flags) */
5353
self::assertSame(['per_page' => 2, 'has_next' => false], $page->metadata());
5454
}
5555

@@ -168,7 +168,7 @@ public function testMapWhenTransformationGivenThenProjectsItemsAndPreservesTheCu
168168
/** @And the next pagination still anchors on the source keys */
169169
self::assertEquals(Pagination::from(cursor: Token::fromKeys(keys: [20]), perPage: 2), $mapped->next());
170170

171-
/** @And the metadata is preserved in length-ascending key order */
171+
/** @And the metadata is preserved in grouped key order (counts and sizes, then the boolean flags) */
172172
self::assertSame(['per_page' => 2, 'has_next' => true], $mapped->metadata());
173173
}
174174

@@ -226,7 +226,7 @@ public function testNavigationWhenExtraElementFetchedThenHasNextAndNextCursorAnc
226226
/** @And the next pagination anchors on the last retained element with the page size */
227227
self::assertEquals(Pagination::from(cursor: Token::fromKeys(keys: [20]), perPage: 2), $page->next());
228228

229-
/** @And the metadata carries the navigation flags in length-ascending key order */
229+
/** @And the metadata carries every entry in grouped key order (counts and sizes, then the boolean flags) */
230230
self::assertSame(['per_page' => 2, 'has_next' => true], $page->metadata());
231231
}
232232
}

tests/Unit/Offset/PageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function testMetadataWhenMiddlePageGivenThenCarriesEveryFlagAndCount(): v
167167
/** @When building the page from the total element count */
168168
$page = $criteria->page(total: 480, items: ['a', 'b']);
169169

170-
/** @Then the metadata carries every navigation flag and count in length-ascending key order */
170+
/** @Then the metadata carries every entry in grouped key order (counts and sizes, then the boolean flags) */
171171
self::assertSame([
172172
'total' => 480,
173173
'per_page' => 20,

tests/Unit/Offset/SliceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testNavigationWhenExtraElementFetchedThenHasNextAndTrimsItems():
9292
/** @And the previous pagination points at the first page */
9393
self::assertSame(1, $slice->previous()?->page());
9494

95-
/** @And the metadata carries every navigation flag and count in length-ascending key order */
95+
/** @And the metadata carries every entry in grouped key order (counts and sizes, then the boolean flags) */
9696
self::assertSame([
9797
'per_page' => 3,
9898
'current_page' => 2,

0 commit comments

Comments
 (0)