Skip to content

Commit f298dd4

Browse files
committed
refactor: respect exception naming convention
1 parent e0d5f8f commit f298dd4

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/support/src/Paginator/Exceptions/InvalidArgumentException.php renamed to packages/support/src/Paginator/Exceptions/ArgumentWasInvalid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
use InvalidArgumentException as PhpInvalidArgumentException;
66

7-
final class InvalidArgumentException extends PhpInvalidArgumentException implements PaginationException
7+
final class ArgumentWasInvalid extends PhpInvalidArgumentException implements PaginationException
88
{
99
}

packages/support/src/Paginator/Paginator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tempest\Support\Paginator;
44

5-
use Tempest\Support\Paginator\Exceptions\InvalidArgumentException;
5+
use Tempest\Support\Paginator\Exceptions\ArgumentWasInvalid;
66

77
final class Paginator
88
{
@@ -13,19 +13,19 @@ public function __construct(
1313
private(set) int $maxLinks = 10,
1414
) {
1515
if ($this->totalItems < 0) {
16-
throw new InvalidArgumentException('Total items cannot be negative');
16+
throw new ArgumentWasInvalid('Total items cannot be negative');
1717
}
1818

1919
if ($this->itemsPerPage <= 0) {
20-
throw new InvalidArgumentException('Items per page must be positive');
20+
throw new ArgumentWasInvalid('Items per page must be positive');
2121
}
2222

2323
if ($this->currentPage <= 0) {
24-
throw new InvalidArgumentException('Current page must be positive');
24+
throw new ArgumentWasInvalid('Current page must be positive');
2525
}
2626

2727
if ($this->maxLinks <= 0) {
28-
throw new InvalidArgumentException('Max links must be positive');
28+
throw new ArgumentWasInvalid('Max links must be positive');
2929
}
3030

3131
$this->currentPage = min(max(1, $this->currentPage), $this->totalPages);

packages/support/tests/Paginator/PaginatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use PHPUnit\Framework\Attributes\DataProvider;
66
use PHPUnit\Framework\Attributes\Test;
77
use PHPUnit\Framework\TestCase;
8-
use Tempest\Support\Paginator\Exceptions\InvalidArgumentException;
8+
use Tempest\Support\Paginator\Exceptions\ArgumentWasInvalid;
99
use Tempest\Support\Paginator\PaginatedData;
1010
use Tempest\Support\Paginator\Paginator;
1111

@@ -116,7 +116,7 @@ public function test_it_constrains_current_page_to_valid_range(): void
116116

117117
$this->assertSame(5, $paginator->currentPage); // Should be capped at max page
118118

119-
$this->expectException(InvalidArgumentException::class);
119+
$this->expectException(ArgumentWasInvalid::class);
120120
$this->createPaginator(currentPage: 0);
121121
}
122122

0 commit comments

Comments
 (0)