Skip to content

Commit c476491

Browse files
Sebastian Molendapubnub-release-bot
andauthored
Support for Members and Membership type, status and include objects (#114)
* Support for Members and Membership type, status and include objects * PubNub SDK 7.3.0 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
1 parent bd89ea0 commit c476491

37 files changed

+2087
-676
lines changed

.pubnub.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
name: php
2-
version: 7.2.1
2+
version: 7.3.0
33
schema: 1
44
scm: github.com/pubnub/php
55
changelog:
6+
- date: 2025-02-05
7+
version: 7.3.0
8+
changes:
9+
- type: feature
10+
text: "Extended functionality of Channel Members and User Membership. Now it's possible to use fine-grade includes and set member/membership status and type."
611
- date: 2025-02-03
712
version: 7.2.1
813
changes:
@@ -442,8 +447,8 @@ sdks:
442447
- x86-64
443448
- distribution-type: library
444449
distribution-repository: GitHub release
445-
package-name: php-7.2.1.zip
446-
location: https://github.com/pubnub/php/releases/tag/7.2.1
450+
package-name: php-7.3.0.zip
451+
location: https://github.com/pubnub/php/releases/tag/7.3.0
447452
requires:
448453
- name: rmccue/requests
449454
min-version: 1.0.0

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 7.3.0
2+
February 05 2025
3+
4+
#### Added
5+
- Extended functionality of Channel Members and User Membership. Now it's possible to use fine-grade includes and set member/membership status and type.
6+
17
## 7.2.1
28
February 03 2025
39

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
4141
{
4242
"require": {
4343
<!-- include the latest version from the badge at the top -->
44-
"pubnub/pubnub": "7.2.1"
44+
"pubnub/pubnub": "7.3.0"
4545
}
4646
}
4747
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": ["api", "real-time", "realtime", "real time", "ajax", "push"],
66
"homepage": "http://www.pubnub.com/",
77
"license": "proprietary",
8-
"version": "7.2.1",
8+
"version": "7.3.0",
99
"authors": [
1010
{
1111
"name": "PubNub",

phpstan-baseline.neon

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,16 +1371,6 @@ parameters:
13711371
count: 1
13721372
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php
13731373

1374-
-
1375-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\GetMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
1376-
count: 1
1377-
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php
1378-
1379-
-
1380-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1381-
count: 1
1382-
path: src/PubNub/Endpoints/Objects/Member/GetMembers.php
1383-
13841374
-
13851375
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\GetMembers\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
13861376
count: 1
@@ -1406,16 +1396,6 @@ parameters:
14061396
count: 1
14071397
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php
14081398

1409-
-
1410-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\RemoveMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
1411-
count: 1
1412-
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php
1413-
1414-
-
1415-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1416-
count: 1
1417-
path: src/PubNub/Endpoints/Objects/Member/RemoveMembers.php
1418-
14191399
-
14201400
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\RemoveMembers\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
14211401
count: 1
@@ -1451,16 +1431,6 @@ parameters:
14511431
count: 1
14521432
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php
14531433

1454-
-
1455-
message: "#^Method PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\SetMembers\\:\\:validateParams\\(\\) has no return type specified\\.$#"
1456-
count: 1
1457-
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php
1458-
1459-
-
1460-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1461-
count: 1
1462-
path: src/PubNub/Endpoints/Objects/Member/SetMembers.php
1463-
14641434
-
14651435
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Member\\\\SetMembers\\:\\:\\$custom type has no value type specified in iterable type array\\.$#"
14661436
count: 1
@@ -1501,11 +1471,6 @@ parameters:
15011471
count: 1
15021472
path: src/PubNub/Endpoints/Objects/Membership/GetMemberships.php
15031473

1504-
-
1505-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1506-
count: 1
1507-
path: src/PubNub/Endpoints/Objects/Membership/GetMemberships.php
1508-
15091474
-
15101475
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\GetMemberships\\:\\:\\$include type has no value type specified in iterable type array\\.$#"
15111476
count: 1
@@ -1536,11 +1501,6 @@ parameters:
15361501
count: 1
15371502
path: src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php
15381503

1539-
-
1540-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1541-
count: 1
1542-
path: src/PubNub/Endpoints/Objects/Membership/RemoveMemberships.php
1543-
15441504
-
15451505
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\RemoveMemberships\\:\\:\\$channels type has no value type specified in iterable type array\\.$#"
15461506
count: 1
@@ -1581,11 +1541,6 @@ parameters:
15811541
count: 1
15821542
path: src/PubNub/Endpoints/Objects/Membership/SetMemberships.php
15831543

1584-
-
1585-
message: "#^PHPDoc tag @throws with type PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\PubNubBuildRequestException is not subtype of Throwable$#"
1586-
count: 1
1587-
path: src/PubNub/Endpoints/Objects/Membership/SetMemberships.php
1588-
15891544
-
15901545
message: "#^Property PubNub\\\\Endpoints\\\\Objects\\\\Membership\\\\SetMemberships\\:\\:\\$channels type has no value type specified in iterable type array\\.$#"
15911546
count: 1

src/PubNub/Endpoints/Endpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function validateSubscribeKey()
130130
{
131131
$subscribeKey = $this->pubnub->getConfiguration()->getSubscribeKey();
132132

133-
if ($subscribeKey == null || empty($subscribeKey)) {
133+
if (strlen($subscribeKey) === 0) {
134134
throw new PubNubValidationException("Subscribe Key not configured");
135135
}
136136
}
@@ -142,7 +142,7 @@ protected function validatePublishKey()
142142
{
143143
$publishKey = $this->pubnub->getConfiguration()->getPublishKey();
144144

145-
if ($publishKey == null || empty($publishKey)) {
145+
if (strlen($publishKey) === 0) {
146146
throw new PubNubValidationException("Publish Key not configured");
147147
}
148148
}

src/PubNub/Endpoints/Objects/Member/GetMembers.php

Lines changed: 41 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,60 @@
66
use PubNub\Enums\PNHttpMethod;
77
use PubNub\Enums\PNOperationType;
88
use PubNub\Exceptions\PubNubValidationException;
9+
use PubNub\Models\Consumer\Objects\Member\PNMemberIncludes;
910
use PubNub\Models\Consumer\Objects\Member\PNMembersResult;
11+
use PubNub\PubNub;
1012

1113
class GetMembers extends ObjectsCollectionEndpoint
1214
{
1315
protected const PATH = "/v2/objects/%s/channels/%s/uuids";
1416

17+
protected bool $endpointAuthRequired = true;
18+
protected string $endpointHttpMethod = PNHttpMethod::GET;
19+
protected int $endpointOperationType = PNOperationType::PNGetMembersOperation;
20+
protected string $endpointName = "GetMembers";
21+
1522
/** @var string */
16-
protected $channel;
23+
protected ?string $channel;
1724

1825
/** @var array */
19-
protected $include = [];
26+
protected array $include = [];
27+
28+
/** @var PNMemberIncludes */
29+
protected ?PNMemberIncludes $includes;
2030

2131
/**
22-
* @param string $ch
32+
* @param PubNub $pubnubInstance
33+
*/
34+
public function __construct(PubNub $pubnubInstance)
35+
{
36+
parent::__construct($pubnubInstance);
37+
$this->endpointConnectTimeout = $this->pubnub->getConfiguration()->getNonSubscribeRequestTimeout();
38+
$this->endpointRequestTimeout = $this->pubnub->getConfiguration()->getConnectTimeout();
39+
}
40+
41+
/**
42+
* @param string $channel
2343
* @return $this
2444
*/
25-
public function channel($ch)
45+
public function channel(string $channel): self
2646
{
27-
$this->channel = $ch;
47+
$this->channel = $channel;
2848

2949
return $this;
3050
}
3151

52+
public function include(PNMemberIncludes $includes): self
53+
{
54+
$this->includes = $includes;
55+
return $this;
56+
}
57+
3258
/**
3359
* @param array $include
3460
* @return $this
3561
*/
36-
public function includeFields($include)
62+
public function includeFields(array $include): self
3763
{
3864
$this->include = $include;
3965

@@ -42,19 +68,20 @@ public function includeFields($include)
4268

4369
/**
4470
* @throws PubNubValidationException
71+
* @return void
4572
*/
4673
protected function validateParams()
4774
{
4875
$this->validateSubscribeKey();
4976

50-
if (!is_string($this->channel)) {
77+
if (empty($this->channel)) {
5178
throw new PubNubValidationException("channel missing");
5279
}
5380
}
5481

5582
/**
5683
* @return string
57-
* @throws PubNubBuildRequestException
84+
* @throws \PubNub\Exceptions\PubNubBuildRequestException
5885
*/
5986
protected function buildData()
6087
{
@@ -94,8 +121,10 @@ protected function customParams()
94121
{
95122
$params = $this->defaultParams();
96123

97-
if (count($this->include) > 0) {
98-
$includes = [];
124+
if (!empty($this->includes)) {
125+
$params['include'] = (string)$this->includes;
126+
} elseif (count($this->include) > 0) {
127+
$includes = [];
99128

100129
if (array_key_exists("customFields", $this->include)) {
101130
array_push($includes, 'custom');
@@ -109,10 +138,8 @@ protected function customParams()
109138
array_push($includes, 'uuid');
110139
}
111140

112-
$includesString = implode(",", $includes);
113-
114-
if (strlen($includesString) > 0) {
115-
$params['include'] = $includesString;
141+
if (!empty($includes)) {
142+
$params['include'] = implode(",", $includes);
116143
}
117144
}
118145

@@ -152,52 +179,4 @@ protected function customParams()
152179

153180
return $params;
154181
}
155-
156-
/**
157-
* @return bool
158-
*/
159-
protected function isAuthRequired()
160-
{
161-
return true;
162-
}
163-
164-
/**
165-
* @return int
166-
*/
167-
protected function getRequestTimeout()
168-
{
169-
return $this->pubnub->getConfiguration()->getNonSubscribeRequestTimeout();
170-
}
171-
172-
/**
173-
* @return int
174-
*/
175-
protected function getConnectTimeout()
176-
{
177-
return $this->pubnub->getConfiguration()->getConnectTimeout();
178-
}
179-
180-
/**
181-
* @return string PNHttpMethod
182-
*/
183-
protected function httpMethod()
184-
{
185-
return PNHttpMethod::GET;
186-
}
187-
188-
/**
189-
* @return int
190-
*/
191-
protected function getOperationType()
192-
{
193-
return PNOperationType::PNGetMembersOperation;
194-
}
195-
196-
/**
197-
* @return string
198-
*/
199-
protected function getName()
200-
{
201-
return "GetMembers";
202-
}
203182
}

0 commit comments

Comments
 (0)