protected function calculateFirstAndLastPage()
    {
        $delta = \floor($this->maximumNumberOfLinks / 2);
        $firstPage = $this->currentPage - $delta;
        $lastPage = $this->currentPage + $delta + ($this->maximumNumberOfLinks % 2 === 0 ? 1 : 0);

        if ($firstPage < 1) {
            $lastPage -= $firstPage - 1;
        }
        if ($lastPage > $this->numberOfPages) {
            $firstPage -= ($lastPage - $this->numberOfPages);
        }

        $this->firstPage = \max($firstPage, 1);
        $this->lastPage = \min($lastPage, $this->numberOfPages);
    }