| Conditions | 3 |
| Paths | 5 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) |
||
| 15 | { |
||
| 16 | try { |
||
| 17 | |||
| 18 | /* |
||
| 19 | * This is the post payload from our PHPUnit tests. |
||
| 20 | * Send it to the connected connections. |
||
| 21 | */ |
||
| 22 | foreach (Socket::$connections as $connection) { |
||
| 23 | $connection->send($request->getBody()); |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | $conn->send(str(new Response(200))); |
||
| 27 | } catch (Exception $e) { |
||
| 28 | $conn->send(str(new Response(500, [], $e->getMessage()))); |
||
| 29 | } |
||
| 30 | |||
| 31 | $conn->close(); |
||
| 32 | } |
||
| 33 | } |
||
| 34 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: