Pol Dellaiera 5432242376
fix: SA: Fix many critical rules.
SA stands for Static Analysis.
2021-11-16 17:13:39 +01:00

47 lines
791 B
PHP

<?php
declare(strict_types=1);
namespace Chill\MainBundle\Pagination;
/**
* PageGenerator associated with a Paginator.
*/
class PageGenerator implements \Iterator
{
protected Paginator $paginator;
protected int $current = 1;
public function __construct(Paginator $paginator)
{
$this->paginator = $paginator;;
}
public function current()
{
return $this->paginator->getPage($current);
}
public function key()
{
return $this->current;
}
public function next()
{
$this->current++;
}
public function rewind()
{
$this->current = 1;
}
public function valid()
{
return $this->current > 0
&& $this->current <= $this->paginator->countPages();
}
}