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

Commit b74144c

Browse files
committed
Revert "wip formatting"
This reverts commit 19ca49a.
1 parent 19ca49a commit b74144c

File tree

11 files changed

+76
-52
lines changed

11 files changed

+76
-52
lines changed

src/API/Controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ protected function handleRequest(ConnectionInterface $connection)
176176

177177
$laravelRequest = Request::createFromBase((new HttpFoundationFactory)->createRequest($serverRequest));
178178

179-
$this->ensureValidAppId($laravelRequest->appId)
179+
$this
180+
->ensureValidAppId($laravelRequest->appId)
180181
->ensureValidSignature($laravelRequest);
181182

182183
// Invoke the controller action

src/Apps/ConfigAppManager.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ public function __construct()
3030
*/
3131
public function all(): array
3232
{
33-
return $this->apps->map(function (array $appAttributes) {
34-
return $this->convertIntoApp($appAttributes);
35-
})->toArray();
33+
return $this->apps
34+
->map(function (array $appAttributes) {
35+
return $this->convertIntoApp($appAttributes);
36+
})
37+
->toArray();
3638
}
3739

3840
/**
@@ -104,7 +106,8 @@ protected function convertIntoApp(?array $appAttributes): ?App
104106
$app->setPath($appAttributes['path']);
105107
}
106108

107-
$app->enableClientMessages($appAttributes['enable_client_messages'])
109+
$app
110+
->enableClientMessages($appAttributes['enable_client_messages'])
108111
->enableStatistics($appAttributes['enable_statistics'])
109112
->setCapacity($appAttributes['capacity'] ?? null)
110113
->setAllowedOrigins($appAttributes['allowed_origins'] ?? []);

src/ChannelManagers/LocalChannelManager.php

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ public function findOrCreate($appId, string $channel)
111111
*/
112112
public function getLocalConnections(): PromiseInterface
113113
{
114-
$connections = collect($this->channels)->map(function ($channelsWithConnections, $appId) {
115-
return collect($channelsWithConnections)->values();
116-
})->values()->collapse()
117-
->map(function ($channel) {
118-
return collect($channel->getConnections());
119-
})->values()->collapse()->toArray();
114+
$connections = collect($this->channels)
115+
->map(function ($channelsWithConnections, $appId) {
116+
return collect($channelsWithConnections)->values();
117+
})
118+
->values()->collapse()
119+
->map(function ($channel) {
120+
return collect($channel->getConnections());
121+
})
122+
->values()->collapse()
123+
->toArray();
120124

121125
return Helpers::createFulfilledPromise($connections);
122126
}
@@ -162,9 +166,11 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro
162166
$this->getLocalChannels($connection->app->id)->then(function ($channels) use ($connection) {
163167
collect($channels)->each->unsubscribe($connection);
164168

165-
collect($channels)->reject->hasConnections()->each(function (Channel $channel, string $channelName) use ($connection) {
166-
unset($this->channels[$connection->app->id][$channelName]);
167-
});
169+
collect($channels)
170+
->reject->hasConnections()
171+
->each(function (Channel $channel, string $channelName) use ($connection) {
172+
unset($this->channels[$connection->app->id][$channelName]);
173+
});
168174
});
169175

170176
$this->getLocalChannels($connection->app->id)->then(function ($channels) use ($connection) {
@@ -249,9 +255,11 @@ public function getLocalConnectionsCount($appId, string $channelName = null): Pr
249255
return $collection->filter(function (Channel $channel) use ($channelName) {
250256
return $channel->getName() === $channelName;
251257
});
252-
})->flatMap(function (Channel $channel) {
258+
})
259+
->flatMap(function (Channel $channel) {
253260
return collect($channel->getConnections())->pluck('socketId');
254-
})->unique()->count();
261+
})
262+
->unique()->count();
255263
});
256264
}
257265

@@ -370,13 +378,14 @@ public function getChannelMember(ConnectionInterface $connection, string $channe
370378
*/
371379
public function getChannelsMembersCount($appId, array $channelNames): PromiseInterface
372380
{
373-
$results = collect($channelNames)->reduce(function ($results, $channel) use ($appId) {
374-
$results[$channel] = isset($this->users["{$appId}:{$channel}"])
375-
? count($this->users["{$appId}:{$channel}"])
376-
: 0;
377-
378-
return $results;
379-
}, []);
381+
$results = collect($channelNames)
382+
->reduce(function ($results, $channel) use ($appId) {
383+
$results[$channel] = isset($this->users["{$appId}:{$channel}"])
384+
? count($this->users["{$appId}:{$channel}"])
385+
: 0;
386+
387+
return $results;
388+
}, []);
380389

381390
return Helpers::createFulfilledPromise($results);
382391
}

src/ChannelManagers/RedisChannelManager.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,14 @@ public function connectionPonged(ConnectionInterface $connection): PromiseInterf
412412
public function removeObsoleteConnections(): PromiseInterface
413413
{
414414
$this->lock()->get(function () {
415-
$this->getConnectionsFromSet(0, now()->subMinutes(2)->format('U'))->then(function ($connections) {
416-
foreach ($connections as $socketId => $appId) {
417-
$connection = $this->fakeConnectionForApp($appId, $socketId);
418-
419-
$this->unsubscribeFromAllChannels($connection);
420-
}
421-
});
415+
$this->getConnectionsFromSet(0, now()->subMinutes(2)->format('U'))
416+
->then(function ($connections) {
417+
foreach ($connections as $socketId => $appId) {
418+
$connection = $this->fakeConnectionForApp($appId, $socketId);
419+
420+
$this->unsubscribeFromAllChannels($connection);
421+
}
422+
});
422423
});
423424

424425
return parent::removeObsoleteConnections();

src/Channels/Channel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public function saveConnection(ConnectionInterface $connection)
155155
*/
156156
public function broadcast($appId, stdClass $payload, bool $replicate = true): bool
157157
{
158-
collect($this->getConnections())->each->send(json_encode($payload));
158+
collect($this->getConnections())
159+
->each->send(json_encode($payload));
159160

160161
if ($replicate) {
161162
$this->channelManager->broadcastAcrossServers($appId, null, $this->getName(), $payload);

src/Statistics/Collectors/MemoryCollector.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function __construct()
4343
*/
4444
public function webSocketMessage($appId)
4545
{
46-
$this->findOrMake($appId)->webSocketMessage();
46+
$this->findOrMake($appId)
47+
->webSocketMessage();
4748
}
4849

4950
/**
@@ -54,7 +55,8 @@ public function webSocketMessage($appId)
5455
*/
5556
public function apiMessage($appId)
5657
{
57-
$this->findOrMake($appId)->apiMessage();
58+
$this->findOrMake($appId)
59+
->apiMessage();
5860
}
5961

6062
/**
@@ -65,7 +67,8 @@ public function apiMessage($appId)
6567
*/
6668
public function connection($appId)
6769
{
68-
$this->findOrMake($appId)->connection();
70+
$this->findOrMake($appId)
71+
->connection();
6972
}
7073

7174
/**
@@ -76,7 +79,8 @@ public function connection($appId)
7679
*/
7780
public function disconnection($appId)
7881
{
79-
$this->findOrMake($appId)->disconnection();
82+
$this->findOrMake($appId)
83+
->disconnection();
8084
}
8185

8286
/**

src/Statistics/Collectors/RedisCollector.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ public function __construct()
5555
*/
5656
public function webSocketMessage($appId)
5757
{
58-
$this->ensureAppIsInSet($appId)->hincrby(
59-
$this->channelManager->getRedisKey($appId, null, ['stats']), 'websocket_messages_count', 1
60-
);
58+
$this->ensureAppIsInSet($appId)
59+
->hincrby($this->channelManager->getRedisKey($appId, null, ['stats']), 'websocket_messages_count', 1);
6160
}
6261

6362
/**
@@ -68,9 +67,8 @@ public function webSocketMessage($appId)
6867
*/
6968
public function apiMessage($appId)
7069
{
71-
$this->ensureAppIsInSet($appId)->hincrby(
72-
$this->channelManager->getRedisKey($appId, null, ['stats']), 'api_messages_count', 1
73-
);
70+
$this->ensureAppIsInSet($appId)
71+
->hincrby($this->channelManager->getRedisKey($appId, null, ['stats']), 'api_messages_count', 1);
7472
}
7573

7674
/**

src/Statistics/Stores/DatabaseStore.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static function delete(Carbon $moment, $appId = null): int
4242
return static::$model::where('created_at', '<', $moment->toDateTimeString())
4343
->when(! is_null($appId), function ($query) use ($appId) {
4444
return $query->whereAppId($appId);
45-
})->delete();
45+
})
46+
->delete();
4647
}
4748

4849
/**
@@ -53,11 +54,12 @@ public static function delete(Carbon $moment, $appId = null): int
5354
*/
5455
public function getRawRecords(callable $processQuery = null)
5556
{
56-
return static::$model::query()->when(! is_null($processQuery), function ($query) use ($processQuery) {
57-
return call_user_func($processQuery, $query);
58-
}, function ($query) {
59-
return $query->latest()->limit(120);
60-
})->get();
57+
return static::$model::query()
58+
->when(! is_null($processQuery), function ($query) use ($processQuery) {
59+
return call_user_func($processQuery, $query);
60+
}, function ($query) {
61+
return $query->latest()->limit(120);
62+
})->get();
6163
}
6264

6365
/**
@@ -72,9 +74,11 @@ public function getRecords(callable $processQuery = null, callable $processColle
7274
return $this->getRawRecords($processQuery)
7375
->when(! is_null($processCollection), function ($collection) use ($processCollection) {
7476
return call_user_func($processCollection, $collection);
75-
})->map(function (Model $statistic) {
77+
})
78+
->map(function (Model $statistic) {
7679
return $this->statisticToArray($statistic);
77-
})->toArray();
80+
})
81+
->toArray();
7882
}
7983

8084
/**

tests/PresenceChannelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ public function test_events_get_replicated_across_connections_for_presence_chann
371371

372372
$receiver->assertSentEvent('some-event', $message->getPayloadAsArray());
373373

374-
$this->getSubscribeClient()->assertNothingDispatched();
374+
$this->getSubscribeClient()
375+
->assertNothingDispatched();
375376

376377
$this->getPublishClient()->assertCalledWithArgs('publish', [
377378
$this->channelManager->getRedisKey('1234', 'presence-channel'),

tests/PrivateChannelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public function test_events_get_replicated_across_connections_for_private_channe
205205

206206
$receiver->assertSentEvent('some-event', $message->getPayloadAsArray());
207207

208-
$this->getSubscribeClient()->assertNothingDispatched();
208+
$this->getSubscribeClient()
209+
->assertNothingDispatched();
209210

210211
$this->getPublishClient()->assertCalledWithArgs('publish', [
211212
$this->channelManager->getRedisKey('1234', 'private-channel'),

0 commit comments

Comments
 (0)