Skip to content

Commit e218665

Browse files
committed
Version 1.1.0, loosen property visibility and allow extending
1 parent 125a751 commit e218665

5 files changed

+40
-33
lines changed

.scrutinizer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
build:
22
environment:
3-
php: 7.3.0
3+
php: 7.4.0
44
nodes:
55
analysis:
66
tests:

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ cache:
88
- $HOME/.composer/cache
99

1010
php:
11-
- 7.3
1211
- 7.4
1312
- 8.0
1413
- nightly

CHANGELOG.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,26 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
55

66
## [Unreleased]
77
### Added
8-
- Bump minimum PHP to 7.3 and support PHP 8. (@MyZik) (#8)
98
### Changed
10-
- Bump development dependencies, update tests.
11-
- Improve all development configurations.
129
### Deprecated
1310
### Removed
1411
### Fixed
1512
### Security
16-
- Minimum PHP 7.3. (@MyZik) (#8)
1713

18-
## [0.1.0] - 2017-09-08
14+
## [1.1.0] - 2021-07-10
15+
### Added
16+
- Bump minimum PHP to 7.4 and support PHP 8. (@MyZik) (#8)
17+
### Changed
18+
- Bump development dependencies, update tests. (#11, #12)
19+
- Improve all development configurations. (#11)
20+
### Fixed
21+
- Strange behaviour with page 3. (#12)
22+
### Security
23+
- Minimum PHP 7.4. (@MyZik) (#8)
24+
25+
## [1.0.0] - 2017-09-08
1926
### Added
2027
- Initial version!
2128

2229
[Unreleased]: https://github.com/php-telegram-bot/inline-keyboard-pagination/compare/master...develop
30+
[1.1.0]: https://github.com/php-telegram-bot/inline-keyboard-pagination/compare/1.0.0...1.1.0

src/InlineKeyboardPagination.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
*/
1212
class InlineKeyboardPagination implements InlineKeyboardPaginator
1313
{
14-
private array $items;
15-
private int $itemsPerPage;
16-
private int $selectedPage;
17-
private int $maxButtons = 5;
18-
private bool $forceButtonCount = false;
19-
private string $command;
20-
private string $callbackDataFormat = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}';
21-
private array $labels = [
14+
protected array $items;
15+
protected int $itemsPerPage;
16+
protected int $selectedPage;
17+
protected int $maxButtons = 5;
18+
protected bool $forceButtonCount = false;
19+
protected string $command;
20+
protected string $callbackDataFormat = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}';
21+
protected array $labels = [
2222
'default' => '%d',
2323
'first' => '« %d',
2424
'previous' => '‹ %d',
@@ -31,10 +31,10 @@ class InlineKeyboardPagination implements InlineKeyboardPaginator
3131
* @param int $maxButtons
3232
* @param bool $forceButtonCount
3333
*
34-
* @return $this
34+
* @return self
3535
* @throws InlineKeyboardPaginationException
3636
*/
37-
public function setMaxButtons(int $maxButtons = 5, bool $forceButtonCount = false): InlineKeyboardPagination
37+
public function setMaxButtons(int $maxButtons = 5, bool $forceButtonCount = false): self
3838
{
3939
if ($maxButtons < 5 || $maxButtons > 8) {
4040
throw InlineKeyboardPaginationException::invalidMaxButtons();
@@ -61,9 +61,9 @@ public function getCallbackDataFormat(): string
6161
*
6262
* @param string $callbackDataFormat
6363
*
64-
* @return InlineKeyboardPagination
64+
* @return self
6565
*/
66-
public function setCallbackDataFormat(string $callbackDataFormat): InlineKeyboardPagination
66+
public function setCallbackDataFormat(string $callbackDataFormat): self
6767
{
6868
$this->callbackDataFormat = $callbackDataFormat;
6969

@@ -85,9 +85,9 @@ public function getLabels(): array
8585
*
8686
* @param array $labels
8787
*
88-
* @return InlineKeyboardPagination
88+
* @return self
8989
*/
90-
public function setLabels(array $labels): InlineKeyboardPagination
90+
public function setLabels(array $labels): self
9191
{
9292
$this->labels = $labels;
9393

@@ -97,7 +97,7 @@ public function setLabels(array $labels): InlineKeyboardPagination
9797
/**
9898
* @inheritdoc
9999
*/
100-
public function setCommand(string $command = 'pagination'): InlineKeyboardPagination
100+
public function setCommand(string $command = 'pagination'): self
101101
{
102102
$this->command = $command;
103103

@@ -108,7 +108,7 @@ public function setCommand(string $command = 'pagination'): InlineKeyboardPagina
108108
* @inheritdoc
109109
* @throws InlineKeyboardPaginationException
110110
*/
111-
public function setSelectedPage(int $selectedPage): InlineKeyboardPagination
111+
public function setSelectedPage(int $selectedPage): self
112112
{
113113
$numberOfPages = $this->getNumberOfPages();
114114
if ($selectedPage < 1 || $selectedPage > $numberOfPages) {
@@ -135,10 +135,10 @@ public function getItemsPerPage(): int
135135
*
136136
* @param int $itemsPerPage
137137
*
138-
* @return InlineKeyboardPagination
138+
* @return self
139139
* @throws InlineKeyboardPaginationException
140140
*/
141-
public function setItemsPerPage(int $itemsPerPage): InlineKeyboardPagination
141+
public function setItemsPerPage(int $itemsPerPage): self
142142
{
143143
if ($itemsPerPage <= 0) {
144144
throw InlineKeyboardPaginationException::invalidItemsPerPage();
@@ -154,10 +154,10 @@ public function setItemsPerPage(int $itemsPerPage): InlineKeyboardPagination
154154
*
155155
* @param array $items
156156
*
157-
* @return InlineKeyboardPagination
157+
* @return self
158158
* @throws InlineKeyboardPaginationException
159159
*/
160-
public function setItems(array $items): InlineKeyboardPagination
160+
public function setItems(array $items): self
161161
{
162162
if (empty($items)) {
163163
throw InlineKeyboardPaginationException::noItems();

src/InlineKeyboardPaginator.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ public function __construct(array $items, string $command, int $selectedPage, in
2525
* @param int $maxButtons
2626
* @param bool $forceButtonCount
2727
*
28-
* @return InlineKeyboardPagination
28+
* @return self
2929
*/
30-
public function setMaxButtons(int $maxButtons = 5, bool $forceButtonCount = false): InlineKeyboardPagination;
30+
public function setMaxButtons(int $maxButtons = 5, bool $forceButtonCount = false): self;
3131

3232
/**
3333
* Set command for this pagination.
3434
*
3535
* @param string $command
3636
*
37-
* @return InlineKeyboardPagination
37+
* @return self
3838
*/
39-
public function setCommand(string $command = 'pagination'): InlineKeyboardPagination;
39+
public function setCommand(string $command = 'pagination'): self;
4040

4141
/**
4242
* Set the selected page.
4343
*
4444
* @param int $selectedPage
4545
*
46-
* @return InlineKeyboardPagination
46+
* @return self
4747
*/
48-
public function setSelectedPage(int $selectedPage): InlineKeyboardPagination;
48+
public function setSelectedPage(int $selectedPage): self;
4949

5050
/**
5151
* Get the pagination data for the passed page.

0 commit comments

Comments
 (0)