Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenadros committed Sep 5, 2024
1 parent fdc9d1f commit 8927e07
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/Paginator/FantaPaginatorAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -68,7 +65,7 @@ public function getSuggests()
*
* @return iterable<array-key, mixed> The slice
*/
public function getSlice(int $offset, int $length): iterable
public function getSlice(int $offset, int $length)
{
return $this->adapter->getResults($offset, $length)->toArray();
}
Expand Down
26 changes: 26 additions & 0 deletions src/Paginator/LegacyAdapterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);

namespace FOS\ElasticaBundle\Paginator;

/**
* @template-covariant T
*/
interface LegacyAdapterInterface
{
/**
* Returns the number of results for the list.
*
* @phpstan-return int<0, max>
*/
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<array-key, T>
*/
public function getSlice(int $offset, int $length);
}

0 comments on commit 8927e07

Please sign in to comment.