|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: siim |
|
5
|
|
|
* Date: 25.01.19 |
|
6
|
|
|
* Time: 17:20 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Sf4\Api\Dto\Traits; |
|
10
|
|
|
|
|
11
|
|
|
trait PaginationTrait |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** @var int $itemsPerPage */ |
|
15
|
|
|
protected $itemsPerPage = 15; |
|
16
|
|
|
|
|
17
|
|
|
/** @var int $totalPages */ |
|
18
|
|
|
protected $totalPages = 0; |
|
19
|
|
|
|
|
20
|
|
|
/** @var int $currentPage */ |
|
21
|
|
|
protected $currentPage = 1; |
|
22
|
|
|
|
|
23
|
|
|
/** @var int|null $nextPage */ |
|
24
|
|
|
protected $nextPage = null; |
|
25
|
|
|
|
|
26
|
|
|
/** @var int|null $previousPage */ |
|
27
|
|
|
protected $previousPage = null; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return int |
|
31
|
|
|
*/ |
|
32
|
|
|
public function getItemsPerPage(): int |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->itemsPerPage; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param int $itemsPerPage |
|
39
|
|
|
*/ |
|
40
|
|
|
public function setItemsPerPage(int $itemsPerPage): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->itemsPerPage = $itemsPerPage; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return int |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getTotalPages(): int |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->totalPages; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param int $totalPages |
|
55
|
|
|
*/ |
|
56
|
|
|
public function setTotalPages(int $totalPages): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->totalPages = $totalPages; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return int |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getCurrentPage(): int |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->currentPage; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param int $currentPage |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setCurrentPage(int $currentPage): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->currentPage = $currentPage; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return int|null |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getNextPage(): ?int |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->nextPage; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param int|null $nextPage |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setNextPage(?int $nextPage): void |
|
89
|
|
|
{ |
|
90
|
|
|
$this->nextPage = $nextPage; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return int|null |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getPreviousPage(): ?int |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->previousPage; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param int|null $previousPage |
|
103
|
|
|
*/ |
|
104
|
|
|
public function setPreviousPage(?int $previousPage): void |
|
105
|
|
|
{ |
|
106
|
|
|
$this->previousPage = $previousPage; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|