@@ -111,16 +111,12 @@ public function findOrCreate($appId, string $channel)
111
111
*/
112
112
public function getLocalConnections (): PromiseInterface
113
113
{
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 ();
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 ();
124
120
125
121
return Helpers::createFulfilledPromise ($ connections );
126
122
}
@@ -166,11 +162,9 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro
166
162
$ this ->getLocalChannels ($ connection ->app ->id )->then (function ($ channels ) use ($ connection ) {
167
163
collect ($ channels )->each ->unsubscribe ($ connection );
168
164
169
- collect ($ channels )
170
- ->reject ->hasConnections ()
171
- ->each (function (Channel $ channel , string $ channelName ) use ($ connection ) {
172
- unset($ this ->channels [$ connection ->app ->id ][$ channelName ]);
173
- });
165
+ collect ($ channels )->reject ->hasConnections ()->each (function (Channel $ channel , string $ channelName ) use ($ connection ) {
166
+ unset($ this ->channels [$ connection ->app ->id ][$ channelName ]);
167
+ });
174
168
});
175
169
176
170
$ this ->getLocalChannels ($ connection ->app ->id )->then (function ($ channels ) use ($ connection ) {
@@ -255,11 +249,9 @@ public function getLocalConnectionsCount($appId, string $channelName = null): Pr
255
249
return $ collection ->filter (function (Channel $ channel ) use ($ channelName ) {
256
250
return $ channel ->getName () === $ channelName ;
257
251
});
258
- })
259
- ->flatMap (function (Channel $ channel ) {
252
+ })->flatMap (function (Channel $ channel ) {
260
253
return collect ($ channel ->getConnections ())->pluck ('socketId ' );
261
- })
262
- ->unique ()->count ();
254
+ })->unique ()->count ();
263
255
});
264
256
}
265
257
@@ -378,14 +370,13 @@ public function getChannelMember(ConnectionInterface $connection, string $channe
378
370
*/
379
371
public function getChannelsMembersCount ($ appId , array $ channelNames ): PromiseInterface
380
372
{
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
- }, []);
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
+ }, []);
389
380
390
381
return Helpers::createFulfilledPromise ($ results );
391
382
}
0 commit comments