1 | <?php |
||
2 | |||
3 | namespace NavigaAdClient\Requests; |
||
4 | |||
5 | use NavigaAdClient\NavigaAdApi; |
||
6 | use NavigaAdClient\Responses\PaginatedResponse; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | class PaginatedRequest |
||
9 | { |
||
10 | protected NavigaAdApi $api; |
||
11 | |||
12 | protected string $endpoint; |
||
13 | protected int $perPage; |
||
14 | protected int $currentPage; |
||
15 | |||
16 | 1 | public function __construct( |
|
17 | NavigaAdApi $api, |
||
18 | string $endpoint, |
||
19 | int $perPage = 20, |
||
20 | int $currentPage = 1, |
||
21 | ) { |
||
22 | 1 | $this->api = $api; |
|
23 | |||
24 | 1 | throw_if(empty($endpoint)); |
|
25 | 1 | $this->endpoint = $endpoint; |
|
26 | |||
27 | 1 | $this->setPerPage($perPage); |
|
28 | 1 | $this->setCurrentPage($currentPage); |
|
29 | } |
||
30 | |||
31 | public function endpoint(): string |
||
32 | { |
||
33 | return $this->endpoint; |
||
34 | } |
||
35 | |||
36 | public function perPage(): int |
||
37 | { |
||
38 | return $this->perPage; |
||
39 | } |
||
40 | |||
41 | public function currentPage(): int |
||
42 | { |
||
43 | return $this->currentPage; |
||
44 | } |
||
45 | |||
46 | 1 | public function setPerPage(int $perPage): static |
|
47 | { |
||
48 | 1 | throw_if($perPage <= 0); |
|
49 | 1 | $this->perPage = $perPage; |
|
50 | |||
51 | 1 | return $this; |
|
52 | } |
||
53 | |||
54 | 1 | public function setCurrentPage(int $currentPage): static |
|
55 | { |
||
56 | 1 | throw_if($currentPage <= 0); |
|
57 | 1 | $this->currentPage = $currentPage; |
|
58 | |||
59 | 1 | return $this; |
|
60 | } |
||
61 | |||
62 | 1 | public function retrieve(array $query = []): PaginatedResponse |
|
63 | { |
||
64 | 1 | $response = $this->api->pendingRequest()->get($this->endpoint, array_merge($query, [ |
|
65 | 1 | 'page' => $this->currentPage, |
|
66 | 1 | 'pageSize' => $this->perPage, |
|
67 | 1 | ])); |
|
68 | |||
69 | 1 | return new PaginatedResponse($response, clone $this, $query); |
|
70 | } |
||
71 | } |
||
72 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths