PaginatorInterface.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Contract;
  12. interface PaginatorInterface
  13. {
  14. /**
  15. * Get the URL for a given page.
  16. */
  17. public function url(int $page): string;
  18. /**
  19. * Add a set of query string values to the paginator.
  20. *
  21. * @param array|string $key
  22. * @return static
  23. */
  24. public function appends($key, ?string $value = null);
  25. /**
  26. * Get / set the URL fragment to be appended to URLs.
  27. *
  28. * @return static|string
  29. */
  30. public function fragment(?string $fragment = null);
  31. /**
  32. * The URL for the next page, or null.
  33. */
  34. public function nextPageUrl(): ?string;
  35. /**
  36. * Get the URL for the previous page, or null.
  37. */
  38. public function previousPageUrl(): ?string;
  39. /**
  40. * Get all of the items being paginated.
  41. */
  42. public function items(): array;
  43. /**
  44. * Get the "index" of the first item being paginated.
  45. */
  46. public function firstItem(): ?int;
  47. /**
  48. * Get the "index" of the last item being paginated.
  49. */
  50. public function lastItem(): ?int;
  51. /**
  52. * Determine how many items are being shown per page.
  53. */
  54. public function perPage(): int;
  55. /**
  56. * Determine the current page being paginated.
  57. */
  58. public function currentPage(): int;
  59. /**
  60. * Determine if there are enough items to split into multiple pages.
  61. */
  62. public function hasPages(): bool;
  63. /**
  64. * Determine if there is more items in the data store.
  65. */
  66. public function hasMorePages(): bool;
  67. /**
  68. * Determine if the list of items is empty or not.
  69. */
  70. public function isEmpty(): bool;
  71. /**
  72. * Determine if the list of items is not empty.
  73. */
  74. public function isNotEmpty(): bool;
  75. /**
  76. * Render the paginator using a given view.
  77. */
  78. public function render(?string $view = null, array $data = []): string;
  79. }