Lines
100.00%
3 / 3
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| PaginatedResult | 100.00% | 3 / 3 | 100.00% | 2 / 2 | 4 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 2 | |||||
| validate | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Districts\Editor\Domain; | |
| 6 | ||
| 7 | use InvalidArgumentException; | |
| 8 | ||
| 9 | /** | |
| 10 | * @template T | |
| 11 | */ | |
| 12 | readonly class PaginatedResult | |
| 13 | { | |
| 14 | /** | |
| 15 | * @param T[] $currentPageEntries | |
| 16 | */ | |
| 17 | public function __construct( | |
| 18 | public Pagination $pagination, | |
| 19 | public int $pageCount, | |
| 20 | public int $totalEntryCount, | |
| 21 | public array $currentPageEntries, | |
| 22 | ) { | |
| 23 | if (!self::validate($pageCount, $totalEntryCount)) { | |
| 24 | throw new InvalidArgumentException(); | |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | private static function validate(int $pageCount, int $totalEntryCount): bool | |
| 29 | { | |
| 30 | return ($pageCount >= 0) && ($totalEntryCount >= 0); | |
| 31 | } | |
| 32 | } |