<?php


namespace App\DAO\Pagination;


use App\Utils\Builder;
use App\Utils\Entity;

class PaginationBuilder implements Builder
{
    private $num_rows;
    private $per_page;
    private $current_page;

    public function setNumRows(int $num_rows): PaginationBuilder
    {
        $this->num_rows = $num_rows;
        return $this;
    }

    public function setPerPage(int $per_page): PaginationBuilder
    {
        $this->per_page = $per_page;
        return $this;
    }

    public function setCurrentPage(int $current_page): PaginationBuilder
    {
        $this->current_page = $current_page;
        return $this;
    }

    public function build() : Pagination
    {
        $pagination = new Pagination();
        if (isset($this->num_rows)) {
            $pagination->setNumRows($this->num_rows);
        }
        if (isset($this->per_page)) {
            $pagination->setPerPage($this->per_page);
        }
        if (isset($this->current_page)) {
            $pagination->setCurrentPage($this->current_page);
        }
        return $pagination;
    }
}