APIRequest.php 1.49 KB
<?php
namespace App\Service\Requests;

use App\Models\Tokens;
use App\Service\API\API;

class APIRequest  implements \App\Service\Contract\APIRequest {
    protected $api;
    protected $service;
    protected $method;
    protected $params;
    protected $token;

    private function __construct($api){
        $this->api = $api;
    }

    static function  getInstance($type){
        switch($type){
            case API::YANDEX:
                return new DirectRequest($type);
        }
    }

    function getApi(): string
    {
        return $this->api;
    }

    function setService(string $service)
    {
        $this->service = $service;
    }

    function getService()
    {
        return $this->service;
    }

    function setMethod(string $method)
    {
        $this->method = $method;
    }

    function getMethod()
    {
        return $this->method;
    }

    function setParams(array $params)
    {
        $this->params = $params;
    }

    function getParams()
    {
        return $this->params;
    }

    function setToken(Tokens $token)
    {
        $this->token = $token;
    }

    function getToken(): Tokens
    {
        return $this->token;
    }

    function chunk($count): ?\App\Service\Contract\APIRequest
    {
        throw new Exception('Я не знаю формата запрсов, чтобы его разбить');
    }

    function next($count)
    {
        throw new Exception('Я не знаю формата запрсов, чтобы его разбить');
    }
}