private function buildPager(AdapterInterface $adapter, Collection $collection, int $startPage): Pagerfanta
    {
        $pager = new Pagerfanta($adapter);

        $pager->setNormalizeOutOfRangePages(true);
        $pager->setMaxPerPage($this->getMaxPerPage($collection));
        $pager->setCurrentPage($startPage > 0 ? $startPage : 1);

        return $pager;
    }