HealthHandler::onError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 2
rs 10
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Server;
4
5
use Exception;
6
use GuzzleHttp\Psr7\Message;
7
use GuzzleHttp\Psr7\Response;
8
use Psr\Http\Message\RequestInterface;
9
use Ratchet\ConnectionInterface;
10
use Ratchet\Http\HttpServerInterface;
11
12
class HealthHandler implements HttpServerInterface
13
{
14
    /**
15
     * Handle the socket opening.
16
     *
17
     * @param  \Ratchet\ConnectionInterface  $connection
18
     * @param  \Psr\Http\Message\RequestInterface  $request
19
     * @return void
20
     */
21
    public function onOpen(ConnectionInterface $connection, RequestInterface $request = null)
22
    {
23
        $response = new Response(
24
            200,
25
            ['Content-Type' => 'application/json'],
26
            json_encode(['ok' => true])
27
        );
28
29
        tap($connection)->send(Message::toString($response))->close();
30
    }
31
32
    /**
33
     * Handle the incoming message.
34
     *
35
     * @param  \Ratchet\ConnectionInterface  $connection
36
     * @param  string  $message
37
     * @return void
38
     */
39
    public function onMessage(ConnectionInterface $connection, $message)
40
    {
41
        //
42
    }
43
44
    /**
45
     * Handle the websocket close.
46
     *
47
     * @param  \Ratchet\ConnectionInterface  $connection
48
     * @return void
49
     */
50
    public function onClose(ConnectionInterface $connection)
51
    {
52
        //
53
    }
54
55
    /**
56
     * Handle the websocket errors.
57
     *
58
     * @param  \Ratchet\ConnectionInterface  $connection
59
     * @param  WebSocketException  $exception
0 ignored issues
show
Bug introduced by
The type BeyondCode\LaravelWebSoc...rver\WebSocketException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
60
     * @return void
61
     */
62
    public function onError(ConnectionInterface $connection, Exception $exception)
63
    {
64
        //
65
    }
66
}
67