Skip to content

Commit a3cbdf8

Browse files
committed
refactor: remove query pagination getter/setter
1 parent dbf9766 commit a3cbdf8

File tree

1 file changed

+3
-53
lines changed

1 file changed

+3
-53
lines changed

src/API/AbstractAPI.php

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,6 @@ abstract class AbstractAPI
3232
*/
3333
public $connection;
3434

35-
/**
36-
* The requested offset.
37-
*
38-
* @var null|int
39-
*/
40-
protected $offset;
41-
42-
/**
43-
* Number of items per request.
44-
*
45-
* @var null|int
46-
*/
47-
protected $limit;
48-
4935
/**
5036
* Create a new API class instance.
5137
*
@@ -56,53 +42,17 @@ public function __construct(Connection $connection)
5642
$this->connection = $connection;
5743
}
5844

59-
public function getOffset(): ?int
60-
{
61-
return $this->offset;
62-
}
63-
64-
public function setOffset(int $offset): API
65-
{
66-
$this->offset = (null === $offset ? $offset : (int) $offset);
67-
68-
return $this;
69-
}
70-
71-
public function getLimit(): ?int
72-
{
73-
return $this->limit;
74-
}
75-
76-
public function setLimit(int $limit): API
77-
{
78-
$this->limit = (null === $limit ? $limit : (int) $limit);
79-
80-
return $this;
81-
}
82-
8345
/**
8446
* Send a GET request with query parameters.
8547
*
8648
* @param string $path
87-
* @param array $parameters
49+
* @param array $query
8850
*
8951
* @return array|string
9052
*/
91-
protected function get(string $path, array $parameters = [])
53+
protected function get(string $path, array $query = [])
9254
{
93-
if (null !== $this->offset && ! isset($parameters['offset'])) {
94-
$parameters['offset'] = $this->offset;
95-
}
96-
97-
if (null !== $this->limit && ! isset($parameters['limit'])) {
98-
$parameters['limit'] = $this->limit;
99-
}
100-
101-
if (count($parameters) > 0) {
102-
$path .= '?'.http_build_query($parameters);
103-
}
104-
105-
$response = $this->connection->getHttpClient()->get($path);
55+
$response = $this->connection->getHttpClient()->get($path, compact('query'));
10656

10757
return json_decode($response->getBody()->getContents(), true);
10858
}

0 commit comments

Comments
 (0)