ChatTopic   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onSubscribe() 0 9 1
A onPublish() 0 8 1
A onUnSubscribe() 0 9 1
1
<?php
2
3
namespace Eole\Websocket\Topic;
4
5
use Ratchet\Wamp\WampConnection;
6
use Eole\Sandstone\Websocket\Topic;
7
8
class ChatTopic extends Topic
9
{
10
    /**
11
     * {@InheritDoc}
12
     */
13
    public function onSubscribe(WampConnection $conn, $topic)
14
    {
15
        parent::onSubscribe($conn, $topic);
16
17
        $this->broadcast([
18
            'type' => 'join',
19
            'player' => $conn->user,
20
        ]);
21
    }
22
23
    /**
24
     * {@InheritDoc}
25
     */
26
    public function onPublish(WampConnection $conn, $topic, $event)
27
    {
28
        $this->broadcast([
29
            'type' => 'message',
30
            'player' => $conn->user,
31
            'message' => $event,
32
        ]);
33
    }
34
35
    /**
36
     * {@InheritDoc}
37
     */
38
    public function onUnSubscribe(WampConnection $conn, $topic)
39
    {
40
        $this->broadcast([
41
            'type' => 'leave',
42
            'player' => $conn->user,
43
        ]);
44
45
        parent::onUnSubscribe($conn, $topic);
46
    }
47
}
48