| Total Complexity | 8 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait UsesQueryParams |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Default query params. |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $params = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Set the "since" pagination query param. |
||
| 18 | * |
||
| 19 | * @param string $id |
||
| 20 | * @return void |
||
| 21 | */ |
||
| 22 | public function since(string $id) |
||
| 23 | { |
||
| 24 | $this->params['since'] = $id; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Set the "before" pagination query param. |
||
| 29 | * |
||
| 30 | * @param string $id |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function before(string $id) |
||
| 34 | { |
||
| 35 | $this->params['before'] = $id; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Set the max number of results to return from the API. |
||
| 40 | * |
||
| 41 | * @param int $limit |
||
| 42 | * @return void |
||
| 43 | */ |
||
| 44 | public function take(int $limit) |
||
| 45 | { |
||
| 46 | $this->params['limit'] = $limit; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Expand a given key in the response. |
||
| 51 | * |
||
| 52 | * @param string|array $params |
||
| 53 | * @return void |
||
| 54 | */ |
||
| 55 | public function expand($params) |
||
| 56 | { |
||
| 57 | $params = is_array($params) ? $params : [$params]; |
||
| 58 | |||
| 59 | $this->params['expand'] = $params; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Return the currently set query parameters. |
||
| 64 | * |
||
| 65 | * @return array |
||
| 66 | */ |
||
| 67 | public function params() |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Set the query parameters for this request. |
||
| 74 | * |
||
| 75 | * @param array $params |
||
| 76 | * @return void |
||
| 77 | */ |
||
| 78 | public function setParams(array $params) |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Build query parameters for this call. |
||
| 85 | * |
||
| 86 | * @param array $query |
||
| 87 | * @return string |
||
| 88 | */ |
||
| 89 | protected function buildQueryParams(array $query) |
||
| 94 | } |
||
| 95 | } |
||
| 96 |