Conditions | 4 |
Paths | 7 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function handle(SpikeInterface $message) |
||
19 | { |
||
20 | $auth = $message->getBody(); |
||
21 | try{ |
||
22 | if (!$this->server->getAuthentication() |
||
23 | || $this->server->getAuthentication()->verify($auth) |
||
24 | ) { |
||
25 | $client = new Client($message->getBody(), $this->connection); |
||
26 | $this->server->getClients()->add($client); |
||
27 | $response = new Spike('auth_response', $client->toArray()); |
||
28 | } else { |
||
29 | $response = new Spike('auth_response', $auth, [ |
||
30 | 'Code' => 200 |
||
31 | ]); |
||
32 | } |
||
33 | } catch (InvalidArgumentException $exception) { |
||
34 | $response = new Spike('auth_response', $auth, [ |
||
35 | 'Code' => 200, |
||
36 | 'message' => $exception->getMessage() |
||
37 | ]); |
||
38 | } |
||
39 | $this->connection->write($response); |
||
40 | } |
||
41 | } |