vendor/friendsofsymfony/elastica-bundle/src/Paginator/FantaPaginatorAdapter.php line 78

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the FOSElasticaBundle package.
  4. *
  5. * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\ElasticaBundle\Paginator;
  11. use Pagerfanta\Adapter\AdapterInterface;
  12. /**
  13. * @template T
  14. *
  15. * @implements AdapterInterface<T>
  16. */
  17. class FantaPaginatorAdapter implements AdapterInterface
  18. {
  19. /**
  20. * @var PaginatorAdapterInterface<T>
  21. *
  22. * @phpstan-ignore-next-line todo: make PaginatorAdapterInterface generic
  23. */
  24. private $adapter;
  25. /**
  26. * @param PaginatorAdapterInterface<T> $adapter
  27. *
  28. * @phpstan-ignore-next-line todo: make PaginatorAdapterInterface generic
  29. */
  30. public function __construct(PaginatorAdapterInterface $adapter)
  31. {
  32. $this->adapter = $adapter;
  33. }
  34. /**
  35. * Returns the number of results.
  36. */
  37. public function getNbResults(): int
  38. {
  39. return $this->adapter->getTotalHits();
  40. }
  41. /**
  42. * Returns Aggregations.
  43. *
  44. * @return array<string, mixed>
  45. *
  46. * @api
  47. */
  48. public function getAggregations()
  49. {
  50. return $this->adapter->getAggregations();
  51. }
  52. /**
  53. * Returns Suggestions.
  54. *
  55. * @return array<string, mixed>
  56. *
  57. * @api
  58. */
  59. public function getSuggests()
  60. {
  61. return $this->adapter->getSuggests();
  62. }
  63. /**
  64. * Returns a slice of the results.
  65. *
  66. * @param int $offset The offset
  67. * @param int $length The length
  68. */
  69. public function getSlice($offset, $length): iterable
  70. {
  71. return $this->adapter->getResults($offset, $length)->toArray();
  72. }
  73. /**
  74. * @return float
  75. */
  76. public function getMaxScore()
  77. {
  78. return $this->adapter->getMaxScore();
  79. }
  80. }