Completed
Push — master ( 4137d9...e7a3c7 )
by dan
02:02
created

PusherManager   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 4 1
A getPusherClient() 0 15 1
A getUserChannelName() 0 4 1
A getChannelName() 0 4 1
A getEvent() 0 4 1
A getAuthKey() 0 4 1
A getSecret() 0 4 1
A getAppId() 0 4 1
A getCluster() 0 4 1
A getEncrypted() 0 4 1
1
<?php
2
3
namespace IrishDan\NotificationBundle;
4
5
/**
6
 * Class PusherManager
7
 *
8
 * @package NotificationBundle
9
 */
10
class PusherManager
11
{
12
    /**
13
     * @var array
14
     */
15
    private $config;
16
17
    public function setConfig(array $config)
18
    {
19
        $this->config = $config;
20
    }
21
22
    /**
23
     * @return \Pusher
24
     */
25
    public function getPusherClient()
26
    {
27
        $options = [
28
            'cluster' => $this->config['cluster'],
29
            'encrypted' => $this->config['encrypted'],
30
        ];
31
        $pusher = new \Pusher(
32
            $this->config['auth_key'],
33
            $this->config['secret'],
34
            $this->config['app_id'],
35
            $options
36
        );
37
38
        return $pusher;
39
    }
40
41
    /**
42
     * @param PusherableInterface $user
43
     * @return string
44
     */
45
    public function getUserChannelName(PusherableInterface $user)
46
    {
47
        return $this->config['channel_name'] . $user->getPusherChannelSuffix();
48
    }
49
50
    /**
51
     * @param $suffix
52
     * @return string
53
     */
54
    public function getChannelName($suffix)
55
    {
56
        return $this->config['channel_name'] . $suffix;
57
    }
58
59
    /**
60
     * @return mixed
61
     */
62
    public function getEvent()
63
    {
64
        return $this->config['event'];
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function getAuthKey()
71
    {
72
        return $this->config['auth_key'];
73
    }
74
75
    /**
76
     * @return mixed
77
     */
78
    public function getSecret()
79
    {
80
        return $this->config['secret'];
81
    }
82
83
    /**
84
     * @return mixed
85
     */
86
    public function getAppId()
87
    {
88
        return $this->config['app_id'];
89
    }
90
91
    /**
92
     * @return mixed
93
     */
94
    public function getCluster()
95
    {
96
        return $this->config['cluster'];
97
    }
98
99
    /**
100
     * @return mixed
101
     */
102
    public function getEncrypted()
103
    {
104
        return $this->config['encrypted'];
105
    }
106
}