Skip to content

Commit 0515ab7

Browse files
Refactor: Changed key names to snake case.
1 parent 38095f9 commit 0515ab7

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/InfiniteScroll.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function make(string $key, Builder|CursorPaginator|Paginator $data, int $
2727
$key => Inertia::defer(fn (): Paginator => $data)->deepMerge(),
2828
'type' => fn (): PaginationType => PaginationType::PAGED,
2929
'page' => fn () => $data->currentPage(),
30-
'hasMore' => fn () => $data->hasMorePages(),
31-
'perPage' => fn (): int => $perPage,
30+
'has_more' => fn () => $data->hasMorePages(),
31+
'per_page' => fn (): int => $perPage,
3232
];
3333
}
3434

@@ -40,8 +40,8 @@ public function make(string $key, Builder|CursorPaginator|Paginator $data, int $
4040
$key => Inertia::defer(fn () => $data)->deepMerge(),
4141
'type' => fn (): PaginationType => PaginationType::CURSOR,
4242
'cursor' => fn () => $data->nextCursor()?->encode(),
43-
'hasMore' => fn () => $data->hasMorePages(), // @phpstan-ignore-line method.notFound
44-
'perPage' => fn (): int => $perPage,
43+
'has_more' => fn () => $data->hasMorePages(), // @phpstan-ignore-line method.notFound
44+
'per_page' => fn (): int => $perPage,
4545
];
4646
}
4747
}

tests/Unit/InfiniteScrollTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
// Assert
2020
expect($result)->toBeArray();
21-
expect(array_keys($result))->toEqual(['test', 'type', 'cursor', 'hasMore', 'perPage']);
21+
expect(array_keys($result))->toEqual(['test', 'type', 'cursor', 'has_more', 'per_page']);
2222
expect($result['test'])->toBeInstanceOf(DeferProp::class);
2323
expect($result['type']())->toBeInstanceOf(PaginationType::class);
2424
expect($result['cursor']())->toBeString();
25-
expect($result['hasMore']())->toBeTrue();
26-
expect($result['perPage']())->toBeInt();
25+
expect($result['has_more']())->toBeTrue();
26+
expect($result['per_page']())->toBeInt();
2727
});
2828

2929
test('returns cursor pagination data given cursor object', function (): void {
@@ -32,20 +32,20 @@
3232

3333
// Assert
3434
expect($result)->toBeArray();
35-
expect(array_keys($result))->toEqual(['test', 'type', 'cursor', 'hasMore', 'perPage']);
35+
expect(array_keys($result))->toEqual(['test', 'type', 'cursor', 'has_more', 'per_page']);
3636
expect($result['test'])->toBeInstanceOf(DeferProp::class);
3737
expect($result['type']())->toBeInstanceOf(PaginationType::class);
3838
expect($result['cursor']())->toBeString();
39-
expect($result['hasMore']())->toBeTrue();
40-
expect($result['perPage']())->toBeInt();
39+
expect($result['has_more']())->toBeTrue();
40+
expect($result['per_page']())->toBeInt();
4141
});
4242

4343
test('determines if cursor pagination has more pages', function (): void {
4444
// Act
4545
$result = InfiniteScroll::make('test', TestModel::query(), 20);
4646

4747
// Assert
48-
expect($result['hasMore']())->toBeFalse();
48+
expect($result['has_more']())->toBeFalse();
4949
});
5050

5151
test('returns pagination data given a pagination object', function (): void {
@@ -54,12 +54,12 @@
5454

5555
// Assert
5656
expect($result)->toBeArray();
57-
expect(array_keys($result))->toEqual(['test', 'type', 'page', 'hasMore', 'perPage']);
57+
expect(array_keys($result))->toEqual(['test', 'type', 'page', 'has_more', 'per_page']);
5858
expect($result['test'])->toBeInstanceOf(DeferProp::class);
5959
expect($result['type']())->toBeInstanceOf(PaginationType::class);
6060
expect($result['page']())->toBeInt();
61-
expect($result['hasMore']())->toBeTrue();
62-
expect($result['perPage']())->toBeInt();
61+
expect($result['has_more']())->toBeTrue();
62+
expect($result['per_page']())->toBeInt();
6363
});
6464

6565
test('returns pagination data given a simple pagination object', function (): void {
@@ -68,18 +68,18 @@
6868

6969
// Assert
7070
expect($result)->toBeArray();
71-
expect(array_keys($result))->toEqual(['test', 'type', 'page', 'hasMore', 'perPage']);
71+
expect(array_keys($result))->toEqual(['test', 'type', 'page', 'has_more', 'per_page']);
7272
expect($result['test'])->toBeInstanceOf(DeferProp::class);
7373
expect($result['type']())->toBeInstanceOf(PaginationType::class);
7474
expect($result['page']())->toBeInt();
75-
expect($result['hasMore']())->toBeTrue();
76-
expect($result['perPage']())->toBeInt();
75+
expect($result['has_more']())->toBeTrue();
76+
expect($result['per_page']())->toBeInt();
7777
});
7878

7979
test('determines if pagination has more pages', function (): void {
8080
// Act
8181
$result = InfiniteScroll::make('test', TestModel::query()->paginate(perPage: 20));
8282

8383
// Assert
84-
expect($result['hasMore']())->toBeFalse();
84+
expect($result['has_more']())->toBeFalse();
8585
});

0 commit comments

Comments
 (0)