Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit bd3aa90

Browse files
committed
Replaced __call with direct function call
1 parent c078e5a commit bd3aa90

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/PubSub/Drivers/RedisClient.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function publish($appId, string $channel, stdClass $payload): bool
104104

105105
$payload = json_encode($payload);
106106

107-
$this->publishClient->__call('publish', [$this->getTopicName($appId, $channel), $payload]);
107+
$this->publishClient->publish($this->getTopicName($appId, $channel), $payload);
108108

109109
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_MESSAGE_PUBLISHED, [
110110
'channel' => $channel,
@@ -127,7 +127,7 @@ public function subscribe($appId, string $channel): bool
127127
{
128128
if (! isset($this->subscribedChannels["{$appId}:{$channel}"])) {
129129
// We're not subscribed to the channel yet, subscribe and set the count to 1
130-
$this->subscribeClient->__call('subscribe', [$this->getTopicName($appId, $channel)]);
130+
$this->subscribeClient->subscribe($this->getTopicName($appId, $channel));
131131
$this->subscribedChannels["{$appId}:{$channel}"] = 1;
132132
} else {
133133
// Increment the subscribe count if we've already subscribed
@@ -161,7 +161,7 @@ public function unsubscribe($appId, string $channel): bool
161161

162162
// If we no longer have subscriptions to that channel, unsubscribe
163163
if ($this->subscribedChannels["{$appId}:{$channel}"] < 1) {
164-
$this->subscribeClient->__call('unsubscribe', [$this->getTopicName($appId, $channel)]);
164+
$this->subscribeClient->unsubscribe($this->getTopicName($appId, $channel));
165165

166166
unset($this->subscribedChannels["{$appId}:{$channel}"]);
167167
}
@@ -183,9 +183,9 @@ public function unsubscribe($appId, string $channel): bool
183183
*/
184184
public function subscribeToApp($appId): bool
185185
{
186-
$this->subscribeClient->__call('subscribe', [$this->getTopicName($appId)]);
186+
$this->subscribeClient->subscribe($this->getTopicName($appId));
187187

188-
$this->publishClient->__call('hincrby', [$this->getTopicName($appId), 'connections', 1]);
188+
$this->publishClient->hincrby($this->getTopicName($appId), 'connections', 1);
189189

190190
return true;
191191
}
@@ -198,9 +198,9 @@ public function subscribeToApp($appId): bool
198198
*/
199199
public function unsubscribeFromApp($appId): bool
200200
{
201-
$this->subscribeClient->__call('unsubscribe', [$this->getTopicName($appId)]);
201+
$this->subscribeClient->unsubscribe($this->getTopicName($appId));
202202

203-
$this->publishClient->__call('hincrby', [$this->getTopicName($appId), 'connections', -1]);
203+
$this->publishClient->hincrby($this->getTopicName($appId), 'connections', -1);
204204

205205
return true;
206206
}
@@ -217,7 +217,7 @@ public function unsubscribeFromApp($appId): bool
217217
*/
218218
public function joinChannel($appId, string $channel, string $socketId, string $data)
219219
{
220-
$this->publishClient->__call('hset', [$this->getTopicName($appId, $channel), $socketId, $data]);
220+
$this->publishClient->hset($this->getTopicName($appId, $channel), $socketId, $data);
221221

222222
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_JOINED_CHANNEL, [
223223
'channel' => $channel,
@@ -239,7 +239,7 @@ public function joinChannel($appId, string $channel, string $socketId, string $d
239239
*/
240240
public function leaveChannel($appId, string $channel, string $socketId)
241241
{
242-
$this->publishClient->__call('hdel', [$this->getTopicName($appId, $channel), $socketId]);
242+
$this->publishClient->hdel($this->getTopicName($appId, $channel), $socketId);
243243

244244
DashboardLogger::log($appId, DashboardLogger::TYPE_REPLICATOR_LEFT_CHANNEL, [
245245
'channel' => $channel,
@@ -258,7 +258,7 @@ public function leaveChannel($appId, string $channel, string $socketId)
258258
*/
259259
public function channelMembers($appId, string $channel): PromiseInterface
260260
{
261-
return $this->publishClient->__call('hgetall', [$this->getTopicName($appId, $channel)])
261+
return $this->publishClient->hgetall($this->getTopicName($appId, $channel))
262262
->then(function ($members) {
263263
// The data is expected as objects, so we need to JSON decode
264264
return array_map(function ($user) {
@@ -279,7 +279,7 @@ public function channelMemberCounts($appId, array $channelNames): PromiseInterfa
279279
$this->publishClient->__call('multi', []);
280280

281281
foreach ($channelNames as $channel) {
282-
$this->publishClient->__call('hlen', [$this->getTopicName($appId, $channel)]);
282+
$this->publishClient->hlen($this->getTopicName($appId, $channel));
283283
}
284284

285285
return $this->publishClient->__call('exec', [])

src/Statistics/Logger/RedisStatisticsLogger.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(ChannelManager $channelManager, StatisticsDriver $dr
5959
public function webSocketMessage($appId)
6060
{
6161
$this->ensureAppIsSet($appId)
62-
->__call('hincrby', [$this->getHash($appId), 'websocket_message_count', 1]);
62+
->hincrby($this->getHash($appId), 'websocket_message_count', 1);
6363
}
6464

6565
/**
@@ -71,7 +71,7 @@ public function webSocketMessage($appId)
7171
public function apiMessage($appId)
7272
{
7373
$this->ensureAppIsSet($appId)
74-
->__call('hincrby', [$this->getHash($appId), 'api_message_count', 1]);
74+
->hincrby($this->getHash($appId), 'api_message_count', 1);
7575
}
7676

7777
/**
@@ -84,13 +84,13 @@ public function connection($appId)
8484
{
8585
// Increment the current connections count by 1.
8686
$incremented = $this->ensureAppIsSet($appId)
87-
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', 1]);
87+
->hincrby($this->getHash($appId), 'current_connection_count', 1);
8888

8989
$incremented->then(function ($currentConnectionCount) use ($appId) {
9090
// Get the peak connections count from Redis.
9191
$peakConnectionCount = $this->replicator
9292
->getPublishClient()
93-
->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
93+
->hget($this->getHash($appId), 'peak_connection_count');
9494

9595
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
9696
// Extract the greatest number between the current peak connection count
@@ -103,7 +103,7 @@ public function connection($appId)
103103
// Then set it to the database.
104104
$this->replicator
105105
->getPublishClient()
106-
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $peakConnectionCount]);
106+
->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount);
107107
});
108108
});
109109
}
@@ -118,13 +118,13 @@ public function disconnection($appId)
118118
{
119119
// Decrement the current connections count by 1.
120120
$decremented = $this->ensureAppIsSet($appId)
121-
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', -1]);
121+
->hincrby($this->getHash($appId), 'current_connection_count', -1);
122122

123123
$decremented->then(function ($currentConnectionCount) use ($appId) {
124124
// Get the peak connections count from Redis.
125125
$peakConnectionCount = $this->replicator
126126
->getPublishClient()
127-
->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
127+
->hget($this->getHash($appId), 'peak_connection_count');
128128

129129
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $appId) {
130130
// Extract the greatest number between the current peak connection count
@@ -137,7 +137,7 @@ public function disconnection($appId)
137137
// Then set it to the database.
138138
$this->replicator
139139
->getPublishClient()
140-
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $peakConnectionCount]);
140+
->hset($this->getHash($appId), 'peak_connection_count', $peakConnectionCount);
141141
});
142142
});
143143
}
@@ -152,13 +152,13 @@ public function save()
152152
$this->lock()->get(function () {
153153
$setMembers = $this->replicator
154154
->getPublishClient()
155-
->__call('smembers', ['laravel-websockets:apps']);
155+
->smembers('laravel-websockets:apps');
156156

157157
$setMembers->then(function ($members) {
158158
foreach ($members as $appId) {
159159
$member = $this->replicator
160160
->getPublishClient()
161-
->__call('hgetall', [$this->getHash($appId)]);
161+
->hgetall($this->getHash($appId));
162162

163163
$member->then(function ($statistic) use ($appId) {
164164
if (! $statistic) {
@@ -201,7 +201,7 @@ protected function ensureAppIsSet($appId)
201201
{
202202
$this->replicator
203203
->getPublishClient()
204-
->__call('sadd', ['laravel-websockets:apps', $appId]);
204+
->sadd('laravel-websockets:apps', $appId);
205205

206206
return $this->replicator->getPublishClient();
207207
}
@@ -217,19 +217,19 @@ public function resetStatistics($appId, int $currentConnectionCount)
217217
{
218218
$this->replicator
219219
->getPublishClient()
220-
->__call('hset', [$this->getHash($appId), 'current_connection_count', $currentConnectionCount]);
220+
->hset($this->getHash($appId), 'current_connection_count', $currentConnectionCount);
221221

222222
$this->replicator
223223
->getPublishClient()
224-
->__call('hset', [$this->getHash($appId), 'peak_connection_count', $currentConnectionCount]);
224+
->hset($this->getHash($appId), 'peak_connection_count', $currentConnectionCount);
225225

226226
$this->replicator
227227
->getPublishClient()
228-
->__call('hset', [$this->getHash($appId), 'websocket_message_count', 0]);
228+
->hset($this->getHash($appId), 'websocket_message_count', 0);
229229

230230
$this->replicator
231231
->getPublishClient()
232-
->__call('hset', [$this->getHash($appId), 'api_message_count', 0]);
232+
->hset($this->getHash($appId), 'api_message_count', 0);
233233
}
234234

235235
/**
@@ -243,23 +243,23 @@ public function resetAppTraces($appId)
243243
{
244244
$this->replicator
245245
->getPublishClient()
246-
->__call('hdel', [$this->getHash($appId), 'current_connection_count']);
246+
->hdel($this->getHash($appId), 'current_connection_count');
247247

248248
$this->replicator
249249
->getPublishClient()
250-
->__call('hdel', [$this->getHash($appId), 'peak_connection_count']);
250+
->hdel($this->getHash($appId), 'peak_connection_count');
251251

252252
$this->replicator
253253
->getPublishClient()
254-
->__call('hdel', [$this->getHash($appId), 'websocket_message_count']);
254+
->hdel($this->getHash($appId), 'websocket_message_count');
255255

256256
$this->replicator
257257
->getPublishClient()
258-
->__call('hdel', [$this->getHash($appId), 'api_message_count']);
258+
->hdel($this->getHash($appId), 'api_message_count');
259259

260260
$this->replicator
261261
->getPublishClient()
262-
->__call('srem', ['laravel-websockets:apps', $appId]);
262+
->srem('laravel-websockets:apps', $appId);
263263
}
264264

265265
/**

0 commit comments

Comments
 (0)