-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPaginationMetadata.php
More file actions
52 lines (46 loc) · 1.19 KB
/
Copy pathPaginationMetadata.php
File metadata and controls
52 lines (46 loc) · 1.19 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
<?php
declare(strict_types=1);
namespace Mindee\V2\Parsing\Search;
use Stringable;
/**
* Pagination metadata.
*/
class PaginationMetadata implements Stringable
{
/**
* @var integer Number of items per page.
*/
public int $perPage;
/**
* @var integer 1-indexed page number.
*/
public int $page;
/**
* @var integer Total number of items.
*/
public int $totalItems;
/**
* @var integer Total number of pages.
*/
public int $totalPages;
/**
* @param array<string, int|float|string|bool|null|array<array-key, mixed>> $rawResponse Raw server response array.
*/
public function __construct(array $rawResponse)
{
$this->perPage = $rawResponse['per_page'];
$this->page = $rawResponse['page'];
$this->totalItems = $rawResponse['total_items'];
$this->totalPages = $rawResponse['total_pages'];
}
/**
* @return string String representation.
*/
public function __toString(): string
{
return ":Per Page: $this->perPage\n"
. ":Page: $this->page\n"
. ":Total Items: $this->totalItems\n"
. ":Total Pages: $this->totalPages\n";
}
}