Application   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 6
c 1
b 0
f 0
dl 0
loc 47
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A onUnSubscribe() 0 2 1
A notify() 0 3 1
A onPublish() 0 3 1
A onError() 0 4 1
A onCall() 0 2 1
A onOpen() 0 5 1
A onSubscribe() 0 2 1
A onClose() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\React\Socket;
6
7
use Exception;
8
use Ratchet\ConnectionInterface;
9
use Ratchet\Wamp\WampServerInterface;
10
11
class Application implements WampServerInterface
12
{
13
    /**
14
     * @param string JSON'ified string we'll receive from ZeroMQ
0 ignored issues
show
Documentation Bug introduced by
The doc comment JSON'ified at position 0 could not be parsed: Unknown type name 'JSON'ified' at position 0 in JSON'ified.
Loading history...
15
     */
16
    public function notify($entry)
17
    {
18
        $entryData = json_decode($entry, true);
0 ignored issues
show
Unused Code introduced by
The assignment to $entryData is dead and can be removed.
Loading history...
19
    }
20
21
    public function onPublish(ConnectionInterface $conn, $topic, $event, array $exclude, array $eligible): void
22
    {
23
        $topic->broadcast($event);
24
    }
25
26
    public function onCall(ConnectionInterface $conn, $id, $topic, array $params): void
27
    {
28
//        $conn->callError($id, $topic, 'RPC not supported on this demo');
29
    }
30
31
    // No need to anything, since WampServer adds and removes subscribers to Topics automatically
32
    public function onSubscribe(ConnectionInterface $conn, $topic): void
33
    {
34
    }
35
36
    public function onUnSubscribe(ConnectionInterface $conn, $topic): void
37
    {
38
39
    }
40
41
    public function onOpen(ConnectionInterface $conn): void
42
    {
43
        // Verify jwt token
44
        // Subscribe user to all required channels|events
45
        echo "onOpen\n";
46
    }
47
48
    public function onClose(ConnectionInterface $conn): void
49
    {
50
        // UnSubscribe user from channels|events
51
        echo "onClose\n";
52
    }
53
54
    public function onError(ConnectionInterface $conn, Exception $e): void
55
    {
56
        // Log error
57
        echo "onError" . $e;
58
    }
59
}
60