From 8927e077e5c73fceedeac0ac0cafbde9f735a167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=C3=A1nchez?= Date: Thu, 5 Sep 2024 08:59:42 +0200 Subject: [PATCH] tests --- src/Paginator/FantaPaginatorAdapter.php | 9 +++----- src/Paginator/LegacyAdapterInterface.php | 26 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/Paginator/LegacyAdapterInterface.php diff --git a/src/Paginator/FantaPaginatorAdapter.php b/src/Paginator/FantaPaginatorAdapter.php index 01b1d6945..32804a06f 100644 --- a/src/Paginator/FantaPaginatorAdapter.php +++ b/src/Paginator/FantaPaginatorAdapter.php @@ -11,15 +11,12 @@ namespace FOS\ElasticaBundle\Paginator; -use Pagerfanta\Adapter\AdapterInterface; -use Traversable; - -class FantaPaginatorAdapter implements AdapterInterface +class FantaPaginatorAdapter implements LegacyAdapterInterface { private $adapter; /** - * @param \FOS\ElasticaBundle\Paginator\PaginatorAdapterInterface $adapter + * @param PaginatorAdapterInterface $adapter */ public function __construct(PaginatorAdapterInterface $adapter) { @@ -68,7 +65,7 @@ public function getSuggests() * * @return iterable The slice */ - public function getSlice(int $offset, int $length): iterable + public function getSlice(int $offset, int $length) { return $this->adapter->getResults($offset, $length)->toArray(); } diff --git a/src/Paginator/LegacyAdapterInterface.php b/src/Paginator/LegacyAdapterInterface.php new file mode 100644 index 000000000..429cfdfef --- /dev/null +++ b/src/Paginator/LegacyAdapterInterface.php @@ -0,0 +1,26 @@ + + */ + public function getNbResults(): int; + + /** + * Returns a slice of the results representing the current page of items in the list. + * + * @phpstan-param int<0, max> $offset + * @phpstan-param int<0, max> $length + * + * @return iterable + */ + public function getSlice(int $offset, int $length); +}