Skip to content

Commit 058506c

Browse files
author
Daniel LaBarge
committed
Fixed bugs in Server. CS fixes.
1 parent ed2022f commit 058506c

17 files changed

+45
-42
lines changed

.php_cs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ return Config::create()
2020
],
2121
'binary_operator_spaces' => [
2222
'align_double_arrow' => true,
23-
'align_equals' => true,
2423
],
2524
])
2625
->setFinder(

src/Broker.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ protected function maxConnections()
284284
protected function resolveMessage($message)
285285
{
286286
$arguments = (array) json_decode($message, true);
287-
$name = array_get($arguments, 'name');
288-
$class = $this->resolveMessageClass($name);
287+
$name = array_get($arguments, 'name');
288+
$class = $this->resolveMessageClass($name);
289289

290290
return new $class($arguments);
291291
}

src/Commands/GetJob.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GetJob extends Command
1212
public function run()
1313
{
1414
$dispatcher = $this->dispatcher();
15-
$job = $dispatcher->connector()
15+
$job = $dispatcher->connector()
1616
->pop($dispatcher->queue());
1717
if ( ! $job) {
1818
return;

src/Commands/NotifyConnection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function __construct(array $arguments = [])
1717
{
1818
parent::__construct($arguments);
1919
$this->receiver = array_get($arguments, 'receiver');
20-
$this->sender = array_get($arguments, 'sender');
20+
$this->sender = array_get($arguments, 'sender');
2121
}
2222

2323
/**
@@ -32,7 +32,7 @@ public function run()
3232

3333
$receiver = $everyone->uuid($this->receiver);
3434

35-
$notification = new Notification($this->sender);
35+
$notification = new Notification($this->sender);
3636
$notifications = $receiver->notifications();
3737
$notifications->put($notification->sender(), $notification);
3838

src/Commands/RunQueuedCommands.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RunQueuedCommands extends Command
1212
public function run()
1313
{
1414
$dispatcher = $this->dispatcher();
15-
$commands = $dispatcher->commands();
15+
$commands = $dispatcher->commands();
1616

1717
$commands->each(function ($command) use ($dispatcher, $commands) {
1818
$dispatcher->run($command);

src/Console/ServerStart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct()
3737
*/
3838
protected function makeSignature()
3939
{
40-
$options = [];
40+
$options = [];
4141
$options[] = '--A|address='.config('server.address').' : The address that the server will bind to for client connections';
4242
$options[] = '--P|port='.config('server.port').' : The port that the server will listen on for client connections';
4343
$options[] = '--Q|queue='.config('server.queue').' : The message queue that the server will be responsible for processing';

src/Contracts/Connection.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
interface Connection extends ConnectionInterface
1010
{
1111
const ANONYMOUS = 'anonymous';
12-
const PLAYER = 'player';
12+
const PLAYER = 'player';
1313
const SPECTATOR = 'spectator';
14-
const WINNER = 'winner';
15-
const LOSER = 'loser';
14+
const WINNER = 'winner';
15+
const LOSER = 'loser';
1616

1717
/**
1818
* Get or set the socket for the connection.

src/Entities/Promise.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function then($promise)
152152
$promise->dispatcher($this->dispatcher());
153153

154154
$this->promises = $this->promises ?: [$this];
155-
$last = end($this->promises);
155+
$last = end($this->promises);
156156
$last->instance()->then(
157157
function ($result) use ($promise) {
158158
return $promise->resolve($result);

src/Entities/Timer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract class Timer implements TimerInterface
1616
protected $counter = 0;
1717
protected $dispatcher;
1818
protected $interval;
19-
protected $paused = false;
19+
protected $paused = false;
2020
protected $started = false;
2121
protected $timeout;
2222
protected $timer;

src/Manager.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ public function queue($name = null)
498498
*/
499499
public function work(Job $job)
500500
{
501-
$payload = $job->getRawBody();
502-
$message = json_decode($payload, true);
501+
$payload = $job->getRawBody();
502+
$message = json_decode($payload, true);
503503
$arguments = array_get($message, 'data', []);
504504

505505
$command = array_get($message, 'job');

src/Messages/CurrentUptime.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class CurrentUptime extends Message implements ServerMessage
1515
*/
1616
public function __construct(Carbon $start)
1717
{
18-
$now = Carbon::now();
18+
$now = Carbon::now();
1919
$this->elapsed = $now->diffInSeconds($start);
20-
$this->start = $start->timestamp;
21-
$this->now = $now->timestamp;
20+
$this->start = $start->timestamp;
21+
$this->now = $now->timestamp;
2222
}
2323
}

src/Messages/JoinAsType.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ abstract class JoinAsType extends Message implements ClientMessage, SelfHandling
2121
public function __construct(array $arguments = [])
2222
{
2323
parent::__construct($arguments);
24-
$this->email = array_get($arguments, 'registration.email', 'Not Available');
24+
$this->email = array_get($arguments, 'registration.email', 'Not Available');
2525
$this->first_name = array_get($arguments, 'registration.name.first');
26-
$this->last_name = array_get($arguments, 'registration.name.last');
27-
$this->type = Connection::ANONYMOUS;
26+
$this->last_name = array_get($arguments, 'registration.name.last');
27+
$this->type = Connection::ANONYMOUS;
2828
}
2929

3030
/**
3131
* Handle the message.
3232
*/
3333
public function handle()
3434
{
35-
$connection = array_filter($this->attributes);
35+
$connection = array_filter($this->attributes);
3636
$connection['uuid'] = $this->client()->uuid();
37-
$command = new RegisterConnection(compact('connection'));
37+
$command = new RegisterConnection(compact('connection'));
3838

3939
return $this->dispatcher()->run($command);
4040
}

src/Messages/MessageException.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MessageException extends Message implements ServerMessage
1616
public function __construct(Exception $exception)
1717
{
1818
$this->exception = get_class($exception);
19-
$this->message = $exception->getMessage();
20-
$this->code = $exception->getCode() ? $exception->getCode() : 400;
19+
$this->message = $exception->getMessage();
20+
$this->code = $exception->getCode() ? $exception->getCode() : 400;
2121
}
2222
}

src/Messages/NotifyConnection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public function __construct(array $arguments = [])
1919
{
2020
parent::__construct($arguments);
2121
$this->receiver = array_get($arguments, 'receiver');
22-
$this->sender = array_get($arguments, 'sender');
22+
$this->sender = array_get($arguments, 'sender');
2323
}
2424
}

src/Messages/PromptForAuthentication.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PromptForAuthentication extends Message implements ServerMessage
1616
public function __construct(ClientMessage $message)
1717
{
1818
$this->previous = $message->toArray();
19-
$this->message = 'Authorization required.';
20-
$this->code = 401;
19+
$this->message = 'Authorization required.';
20+
$this->code = 401;
2121
}
2222
}

src/Server.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Server implements ServerInterface
2626
protected $http;
2727
protected $manager;
2828
protected $output;
29-
protected $port = 8080;
29+
protected $port = 8080;
3030
protected $queue = 'default';
3131
protected $socket;
3232
protected $websocket;
@@ -302,12 +302,12 @@ public function usesQueue($connection = null, $name = null)
302302
public function connector(Queue $instance = null)
303303
{
304304
if ( ! is_null($instance)) {
305-
$this->config(__FUNCTION__, $instance);
306-
}
305+
$this->manager->connector($instance);
307306

308-
$this->manager()->connector($instance);
307+
return $this;
308+
}
309309

310-
return $this;
310+
return $this->manager()->connector();
311311
}
312312

313313
/**
@@ -323,12 +323,12 @@ public function connector(Queue $instance = null)
323323
public function queue($name = null)
324324
{
325325
if ( ! is_null($name)) {
326-
$this->config(__FUNCTION__, $name);
327-
}
326+
$this->manager()->queue($name);
328327

329-
$this->manager()->queue($name);
328+
return $this;
329+
}
330330

331-
return $this;
331+
return $this->manager()->queue();
332332
}
333333

334334
/**
@@ -343,9 +343,13 @@ public function queue($name = null)
343343
*/
344344
public function logger(OutputInterface $interface = null)
345345
{
346-
$this->broker()->logger($interface);
346+
if ( ! is_null($interface)) {
347+
$this->broker()->logger($interface);
347348

348-
return $this;
349+
return $this;
350+
}
351+
352+
return $this->broker()->logger();
349353
}
350354

351355
/**

src/Traits/AwsAsyncHelpers.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ trait AwsAsyncHelpers
1919
*/
2020
protected function awsHttpHandler()
2121
{
22-
$loop = Server::instance()->loop();
22+
$loop = Server::instance()->loop();
2323
$adapter = new HttpClientAdapter($loop);
2424
$handler = HandlerStack::create($adapter);
25-
$client = new GuzzleClient(['handler' => $handler]);
25+
$client = new GuzzleClient(['handler' => $handler]);
2626

2727
return new GuzzleHandler($client);
2828
}
@@ -65,7 +65,7 @@ protected function awsS3($region = null)
6565
*/
6666
protected function awsS3Credentials()
6767
{
68-
$key = $this->awsS3Config('key');
68+
$key = $this->awsS3Config('key');
6969
$secret = $this->awsS3Config('secret');
7070

7171
return compact('key', 'secret');

0 commit comments

Comments
 (0)