Skip to content

Commit 7d3b6b0

Browse files
Re-worked pagination
1 parent 408734e commit 7d3b6b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+171
-230
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGE LOG
66

77
* Dropped support for PHP 7.1
88
* Made builder class final
9+
* Re-worked pagination
910

1011

1112
## V3.3 (27/11/2020)

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Variable method call on Bitbucket\\\\Api\\\\ApiInterface\\.$#"
4+
message: "#^Variable method call on Bitbucket\\\\Api\\\\AbstractApi\\.$#"
55
count: 1
66
path: src/ResultPager.php
77

psalm-baseline.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@
88
<code>\get_debug_type($data)</code>
99
</UndefinedFunction>
1010
</file>
11+
<file src="src/ResultPager.php">
12+
<InaccessibleProperty occurrences="1">
13+
<code>$clone-&gt;perPage</code>
14+
</InaccessibleProperty>
15+
<PossiblyInvalidFunctionCall occurrences="1">
16+
<code>$closure($api)</code>
17+
</PossiblyInvalidFunctionCall>
18+
</file>
1119
</files>

src/Api/AbstractApi.php

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
use Bitbucket\HttpClient\Message\ResponseMediator;
1818
use Bitbucket\HttpClient\Util\JsonArray;
1919
use Bitbucket\HttpClient\Util\QueryStringBuilder;
20-
use ValueError;
2120

2221
/**
2322
* @author Joseph Bielawski <[email protected]>
2423
* @author Graham Campbell <[email protected]>
2524
*/
26-
abstract class AbstractApi implements ApiInterface
25+
abstract class AbstractApi
2726
{
2827
/**
2928
* The URI prefix.
@@ -49,19 +48,13 @@ abstract class AbstractApi implements ApiInterface
4948
/**
5049
* Create a new API instance.
5150
*
52-
* @param Client $client
53-
* @param int|null $perPage
51+
* @param Client $client
5452
*
5553
* @return void
5654
*/
57-
public function __construct(Client $client, int $perPage = null)
55+
public function __construct(Client $client)
5856
{
59-
if (null !== $perPage && ($perPage < 1 || $perPage > 100)) {
60-
throw new ValueError(\sprintf('%s::__construct(): Argument #2 ($perPage) must be between 1 and 100, or null', self::class));
61-
}
62-
6357
$this->client = $client;
64-
$this->perPage = $perPage;
6558
}
6659

6760
/**
@@ -74,38 +67,6 @@ protected function getClient()
7467
return $this->client;
7568
}
7669

77-
/**
78-
* Get the number of values to fetch per page.
79-
*
80-
* @return int|null
81-
*/
82-
protected function getPerPage()
83-
{
84-
return $this->perPage;
85-
}
86-
87-
/**
88-
* Create a new instance with the given page parameter.
89-
*
90-
* This must be an integer between 1 and 100.
91-
*
92-
* @param int|null $perPage
93-
*
94-
* @return static
95-
*/
96-
public function perPage(int $perPage = null)
97-
{
98-
if (null !== $perPage && ($perPage < 1 || $perPage > 100)) {
99-
throw new ValueError(\sprintf('%s::perPage(): Argument #1 ($perPage) must be between 1 and 100, or null', self::class));
100-
}
101-
102-
$copy = clone $this;
103-
104-
$copy->perPage = $perPage;
105-
106-
return $copy;
107-
}
108-
10970
/**
11071
* Send a GET request with query params and return the raw response.
11172
*

src/Api/Addon.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ public function remove(array $params = [])
5757
*/
5858
public function linkers()
5959
{
60-
return new Linkers($this->getClient(), $this->getPerPage());
60+
return new Linkers($this->getClient());
6161
}
6262

6363
/**
6464
* @return \Bitbucket\Api\Addon\Users
6565
*/
6666
public function users()
6767
{
68-
return new UsersAddon($this->getClient(), $this->getPerPage());
68+
return new UsersAddon($this->getClient());
6969
}
7070

7171
/**

src/Api/Addon/Linkers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function show(string $linker, array $params = [])
5959
*/
6060
public function values(string $linker)
6161
{
62-
return new Values($this->getClient(), $linker, $this->getPerPage());
62+
return new Values($this->getClient(), $linker);
6363
}
6464

6565
/**

src/Api/Addon/Linkers/AbstractLinkersApi.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ abstract class AbstractLinkersApi extends AbstractAddonApi
3535
*
3636
* @param Client $client
3737
* @param string $linker
38-
* @param int|null $perPage
3938
*
4039
* @return void
4140
*/
42-
public function __construct(Client $client, string $linker, int $perPage = null)
41+
public function __construct(Client $client, string $linker)
4342
{
44-
parent::__construct($client, $perPage);
43+
parent::__construct($client);
4544
$this->linker = $linker;
4645
}
4746
}

src/Api/Addon/Users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class Users extends AbstractAddonApi
2929
*/
3030
public function events(string $username)
3131
{
32-
return new Events($this->getClient(), $username, $this->getPerPage());
32+
return new Events($this->getClient(), $username);
3333
}
3434
}

src/Api/Addon/Users/AbstractUsersApi.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ abstract class AbstractUsersApi extends AbstractAddonApi
3535
*
3636
* @param Client $client
3737
* @param string $username
38-
* @param int|null $perPage
3938
*
4039
* @return void
4140
*/
42-
public function __construct(Client $client, string $username, int $perPage = null)
41+
public function __construct(Client $client, string $username)
4342
{
44-
parent::__construct($client, $perPage);
43+
parent::__construct($client);
4544
$this->username = $username;
4645
}
4746
}

src/Api/ApiInterface.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)