Skip to content

Commit 9f9ba18

Browse files
committed
codestyle fixes
1 parent 0e5c0f9 commit 9f9ba18

File tree

1 file changed

+35
-40
lines changed

1 file changed

+35
-40
lines changed

src/AsyncClient.php

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ final class AsyncClient
1919

2020
protected $noActivityTimeout = self::NO_ACTIVITY_TIMEOUT;
2121

22-
/**
23-
* @var LoopInterface
24-
*/
25-
protected $loop;
26-
2722
/**
2823
* @var Observable\RefCountObservable
2924
*/
@@ -49,39 +44,11 @@ final class AsyncClient
4944
*/
5045
protected $delay = 200;
5146

52-
/**
53-
* @param LoopInterface $loop
54-
* @param string $app Application ID
55-
* @param Resolver $resolver Optional DNS resolver
56-
* @return AsyncClient
57-
*/
58-
public static function create(LoopInterface $loop, string $app, Resolver $resolver = null): AsyncClient
59-
{
60-
try {
61-
Scheduler::setAsyncFactory(function () use ($loop) {
62-
return new Scheduler\EventLoopScheduler($loop);
63-
});
64-
} catch (Throwable $t) {
65-
}
66-
67-
return new self(
68-
$loop,
69-
new WebsocketClient(
70-
ApiSettings::createUrl($app),
71-
false,
72-
[],
73-
$loop,
74-
$resolver
75-
)
76-
);
77-
}
78-
7947
/**
8048
* @internal
8149
*/
82-
public function __construct(LoopInterface $loop, WebsocketClient $client)
50+
public function __construct(Observable $client)
8351
{
84-
$this->loop = $loop;
8552
$this->messages = $client
8653
// Save this subject for sending stuff
8754
->do(function (MessageSubject $ms) {
@@ -144,9 +111,35 @@ public function __construct(LoopInterface $loop, WebsocketClient $client)
144111
}
145112

146113
/**
147-
* Listen on a channel
114+
* @param LoopInterface $loop
115+
* @param string $app Application ID
116+
* @param Resolver $resolver Optional DNS resolver
117+
* @return AsyncClient
118+
*/
119+
public static function create(LoopInterface $loop, string $app, Resolver $resolver = null): AsyncClient
120+
{
121+
try {
122+
Scheduler::setAsyncFactory(function () use ($loop) {
123+
return new Scheduler\EventLoopScheduler($loop);
124+
});
125+
} catch (Throwable $t) {
126+
}
127+
128+
return new self(
129+
new WebsocketClient(
130+
ApiSettings::createUrl($app),
131+
false,
132+
[],
133+
$loop,
134+
$resolver
135+
)
136+
);
137+
}
138+
139+
/**
140+
* Listen on a channel.
148141
*
149-
* @param string $channel Channel to listen on
142+
* @param string $channel Channel to listen on
150143
* @return Observable
151144
*/
152145
public function channel(string $channel): Observable
@@ -186,16 +179,17 @@ public function channel(string $channel): Observable
186179

187180
// Share stream amount subscribers to this channel
188181
$this->channels[$channel] = $events->share();
182+
189183
return $this->channels[$channel];
190184
}
191185

192186
/**
193-
* Send a message through the client
187+
* Send a message through the client.
194188
*
195189
* @param array $message Message to send, will be json encoded
196190
*
197191
* @return A bool indicating whether or not the connection was active
198-
* and the given message has been pass onto the connection.
192+
* and the given message has been pass onto the connection.
199193
*/
200194
public function send(array $message): bool
201195
{
@@ -205,12 +199,14 @@ public function send(array $message): bool
205199
}
206200

207201
$this->sendSubject->onNext(json_encode($message));
202+
208203
return true;
209204
}
210205

211206
private function handleLowLevelError(Throwable $throwable)
212207
{
213208
$this->delay *= 2;
209+
214210
return Observable::timer($this->delay);
215211
}
216212

@@ -222,9 +218,8 @@ private function subscribeOnChannel(string $channel)
222218
$this->send(['event' => 'pusher:subscribe', 'data' => ['channel' => $channel]]);
223219
}
224220

225-
226221
/**
227-
* Get connection activity timeout from connection established event
222+
* Get connection activity timeout from connection established event.
228223
*
229224
* @param Event $event
230225
*/

0 commit comments

Comments
 (0)