for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Sirius\Orm\Collection;
class PaginatedCollection extends Collection
{
protected $totalCount;
protected $perPage;
protected $currentPage;
public function __construct(array $elements, int $totalCount, int $perPage, int $currentPage)
parent::__construct($elements);
$this->totalCount = $totalCount;
$this->perPage = $perPage;
$this->currentPage = $currentPage;
}
/**
* @return mixed
*/
public function getTotalCount()
return $this->totalCount;
public function getPerPage()
return $this->perPage;
public function getCurrentPage()
return $this->currentPage;
public function getTotalPages()
if ($this->perPage < 1) {
return 0;
return ceil($this->totalCount / $this->perPage);
public function getPageStart()
if ($this->totalCount < 1) {
return 1 + $this->perPage * ($this->currentPage - 1);
public function getPageEnd()
return $this->getPageStart() + $this->count() - 1;