Skip to content

Commit 201d55d

Browse files
authored
Use protected properties and methods in WebPush class (#324)
This allows other projects to extend the WebPush class and alter the way it works. An example use-case is to replace Guzzle with a ReactPHP based HTTP client for better integration in long-running asynchronous processes.
1 parent 256a18b commit 201d55d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/WebPush.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,37 @@ class WebPush
2424
/**
2525
* @var Client
2626
*/
27-
private $client;
27+
protected $client;
2828

2929
/**
3030
* @var array
3131
*/
32-
private $auth;
32+
protected $auth;
3333

3434
/**
3535
* @var null|array Array of array of Notifications
3636
*/
37-
private $notifications;
37+
protected $notifications;
3838

3939
/**
4040
* @var array Default options : TTL, urgency, topic, batchSize
4141
*/
42-
private $defaultOptions;
42+
protected $defaultOptions;
4343

4444
/**
4545
* @var int Automatic padding of payloads, if disabled, trade security for bandwidth
4646
*/
47-
private $automaticPadding = Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH;
47+
protected $automaticPadding = Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH;
4848

4949
/**
5050
* @var bool Reuse VAPID headers in the same flush session to improve performance
5151
*/
52-
private $reuseVAPIDHeaders = false;
52+
protected $reuseVAPIDHeaders = false;
5353

5454
/**
5555
* @var array Dictionary for VAPID headers cache
5656
*/
57-
private $vapidHeaders = [];
57+
protected $vapidHeaders = [];
5858

5959
/**
6060
* WebPush constructor.
@@ -203,7 +203,7 @@ public function flush(?int $batchSize = null): \Generator
203203
*
204204
* @throws \ErrorException
205205
*/
206-
private function prepare(array $notifications): array
206+
protected function prepare(array $notifications): array
207207
{
208208
$requests = [];
209209
foreach ($notifications as $notification) {
@@ -383,7 +383,7 @@ public function countPendingNotifications(): int
383383
* @return array
384384
* @throws \ErrorException
385385
*/
386-
private function getVAPIDHeaders(string $audience, string $contentEncoding, array $vapid)
386+
protected function getVAPIDHeaders(string $audience, string $contentEncoding, array $vapid)
387387
{
388388
$vapidHeaders = null;
389389

0 commit comments

Comments
 (0)