Completed
Push — master ( db8ff8...4137d9 )
by dan
01:59
created

PusherManager::setConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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
    /**
18
     * PusherManager constructor.
19
     *
20
     * @param array $config
21
     */
22
    public function __construct(array $config)
23
    {
24
        $this->config = $config;
25
    }
26
27
    /**
28
     * @return \Pusher
29
     */
30
    public function getPusherClient()
31
    {
32
        $options = [
33
            'cluster' => $this->config['cluster'],
34
            'encrypted' => $this->config['encrypted'],
35
        ];
36
        $pusher = new \Pusher(
37
            $this->config['auth_key'],
38
            $this->config['secret'],
39
            $this->config['app_id'],
40
            $options
41
        );
42
43
        return $pusher;
44
    }
45
46
    public function setConfig(array $config)
47
    {
48
        $this->config = $config;
49
    }
50
51
    /**
52
     * @param PusherableInterface $user
53
     * @return string
54
     */
55
    public function getUserChannelName(PusherableInterface $user)
56
    {
57
        return $this->config['channel_name'] . $user->getPusherChannelSuffix();
58
    }
59
60
    /**
61
     * @param $suffix
62
     * @return string
63
     */
64
    public function getChannelName($suffix)
65
    {
66
        return $this->config['channel_name'] . $suffix;
67
    }
68
69
    /**
70
     * @return mixed
71
     */
72
    public function getEvent()
73
    {
74
        return $this->config['event'];
75
    }
76
77
    /**
78
     * @return mixed
79
     */
80
    public function getAuthKey()
81
    {
82
        return $this->config['auth_key'];
83
    }
84
85
    /**
86
     * @return mixed
87
     */
88
    public function getSecret()
89
    {
90
        return $this->config['secret'];
91
    }
92
93
    /**
94
     * @return mixed
95
     */
96
    public function getAppId()
97
    {
98
        return $this->config['app_id'];
99
    }
100
101
    /**
102
     * @return mixed
103
     */
104
    public function getCluster()
105
    {
106
        return $this->config['cluster'];
107
    }
108
109
    /**
110
     * @return mixed
111
     */
112
    public function getEncrypted()
113
    {
114
        return $this->config['encrypted'];
115
    }
116
}