Topic   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 73
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setNormalizer() 0 6 1
A broadcast() 0 4 1
A onSubscribe() 0 4 1
A onPublish() 0 4 1
A onUnSubscribe() 0 4 1
1
<?php
2
3
namespace Eole\Sandstone\Websocket;
4
5
use JMS\Serializer\ArrayTransformerInterface;
6
use Ratchet\Wamp\WampConnection;
7
use Ratchet\Wamp\Topic as BaseTopic;
8
9
class Topic extends BaseTopic
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $arguments;
15
16
    /**
17
     * @var ArrayTransformerInterface
18
     */
19
    protected $normalizer;
20
21
    /**
22
     * @param string $topicPath
23
     * @param array $arguments
24
     */
25
    public function __construct($topicPath, array $arguments = array())
26
    {
27
        parent::__construct($topicPath);
28
29
        $this->arguments = $arguments;
30
    }
31
32
    /**
33
     * @param ArrayTransformerInterface $normalizer
34
     *
35
     * @return self
36
     */
37
    public function setNormalizer(ArrayTransformerInterface $normalizer)
38
    {
39
        $this->normalizer = $normalizer;
40
41
        return $this;
42
    }
43
44
    /**
45
     * {@InheritDoc}
46
     *
47
     * And normalize message using the serializer before send.
48
     */
49
    public function broadcast($msg, array $exclude = array(), array $eligible = array())
50
    {
51
        parent::broadcast($this->normalizer->toArray($msg), $exclude, $eligible);
52
    }
53
54
    /**
55
     * @param WampConnection $conn
56
     * @param string $topic
57
     */
58
    public function onSubscribe(WampConnection $conn, $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        $this->add($conn);
61
    }
62
63
    /**
64
     * @param WampConnection $conn
65
     * @param string $topic
66
     * @param string $event
67
     */
68
    public function onPublish(WampConnection $conn, $topic, $event)
0 ignored issues
show
Unused Code introduced by
The parameter $conn is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
69
    {
70
        // noop
71
    }
72
73
    /**
74
     * @param WampConnection $conn
75
     * @param string $topic
76
     */
77
    public function onUnSubscribe(WampConnection $conn, $topic)
0 ignored issues
show
Unused Code introduced by
The parameter $topic is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
    {
79
        $this->remove($conn);
80
    }
81
}
82