<?php namespace App\DAO\DAOResponse;



use App\DAO\Pagination\Pagination;
use App\Utils\ResponseAbstract\ResponseBuilderAbstract;

class DAOResponseBuilder extends ResponseBuilderAbstract
{
    private $pagination;

    public function setStatus(int $status): DAOResponseBuilder
    {
        $this->status = $status;
        return $this;
    }

    public function setData($data): DAOResponseBuilder
    {
        $this->data = $data;
        return $this;
    }

    public function setErrors(array $errors): DAOResponseBuilder
    {
        $this->errors = $errors;
        return $this;
    }

    public function setPagination(?Pagination $pagination): DAOResponseBuilder
    {
        $this->pagination = $pagination;
        return $this;
    }

    public function build() : DAOResponse
    {
        $service_response = new DAOResponse();
        $service_response->setstatus($this->status);
        if (isset($this->data)) {
            $service_response->setdata($this->data);
        }
        if (isset($this->errors)) {
            $service_response->seterrors($this->errors);
        }
        if (isset($this->pagination)){
            $service_response->setPagination($this->pagination);
        }
        return $service_response;
    }
}