DirectRequest.php
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace App\Service\Requests;
use App\Models\Tokens;
/**
* Class DirectRequest
* @package App\Service\Requests
*
*
*/
class DirectRequest extends APIRequest {
CONST MAX_COUNT = 10000;
function chunk($count): ?\App\Service\Contract\APIRequest
{
//для запросов get ничего не разбиваем, т.к. заранее не знаем сколько чего будет
//для них только после выполнения запроса будет известно есть ли кроме $count еще данные
//а текущий запрос просто устанавливается в $count
//а вот для запросов мутатрово будем разбивать. Но тут уже будет зависеть от запроса
//будем под каждый реализовывать делитель
if (!isset($this->params['Page'])){
$this->params['Page'] = [];
}
$this->params['Page']['Limit'] = $count;
return null;
// if (!isset($this->params['Page'])){
// $this->params['Page']['Limit'] = $count;
// $this->params['Page']['Offset'] = 0;
// return null;
// }
// if ($this->params['Page']['Limit'] <= $count) {
// return null;
// }
//
// $this->params['Page']['Limit'] = $count;
//
// $new = clone $this;
// $params = $this->params;
// $params['Page']['Offset'] += $count;
// $new->setParams($params);
// return $new;
}
function next($offset){
if (!isset($this->params['Page'])){
$this->params['Page'] = [];
}
$this->params['Page']['Limit'] = self::MAX_COUNT;
$this->params['Page']['Offset'] = $offset;
}
}