<?php namespace App\DAO\Order;
use App\Utils\Builder;

class QueryOrderBuilder implements Builder
{
    private $name_param;
    private $table;
    private $desc;

    public function setNameParam(string $name_param) : QueryOrderBuilder
    {
        $this->name_param = $name_param;
        return $this;
    }

    public function setTable(string $table) : QueryOrderBuilder
    {
        $this->table = $table;
        return $this;
    }

    public function setDesc(bool $desc) : QueryOrderBuilder
    {
        $this->desc = $desc;
        return $this;
    }


    public function setOrderWay(string $order_way)
    {
        $translator_order_way_to_desc = [
            '' => false,
            '-' => true
        ];
        $this->desc = $translator_order_way_to_desc[$order_way];
        return $this;
    }

    public function build() : QueryOrder
    {
        $query_order = new QueryOrder();
        $query_order->setnameparam($this->name_param);
        $query_order->settable($this->table);
        $query_order->setDesc($this->desc);
        return $query_order;
    }
}