Completed
Pull Request — master (#4)
by dan
14:39
created

BaseChannel::setChannelName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Channel;
4
5
use IrishDan\NotificationBundle\Adapter\MessageAdapterInterface;
6
7
/**
8
 * Class BaseChannel
9
 *
10
 * @package IrishDan\NotificationBundle\Channel
11
 */
12
abstract class BaseChannel implements ChannelInterface
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $channelConfiguration;
18
    /**
19
     * @var
20
     */
21
    protected $channelName;
22
    /**
23
     * @var
24
     */
25
    protected $adapter;
26
27
    public function __construct(array $channelConfiguration = [], $channelName = null, MessageAdapterInterface $adapter = null)
28
    {
29
        $this->channelConfiguration = $channelConfiguration;
30
31
        $this->channelName = $channelName;
32
33
        if (!empty($adapter)) {
34
            // The adapter needs the channel name and the configurations.
35
            $adapter->setChannelName($channelName);
36
            $adapter->setConfiguration($channelConfiguration);
37
38
            $this->adapter = $adapter;
39
        }
40
    }
41
42
    /**
43
     * @param array $channelConfiguration
44
     */
45
    public function setChannelConfiguration(array $channelConfiguration): void
46
    {
47
        $this->channelConfiguration = $channelConfiguration;
48
    }
49
50
    /**
51
     * @param mixed $channelName
52
     */
53
    public function setChannelName(string $channelName): void
54
    {
55
        $this->channelName = $channelName;
56
    }
57
58
    public function setAdapter(MessageAdapterInterface $adapter): void
59
    {
60
        $this->adapter = $adapter;
61
    }
62
63
    /**
64
     * @return mixed
65
     */
66
    public function channelName()
67
    {
68
        return $this->channelName;
69
    }
70
71
    public function getConfiguration()
72
    {
73
        return $this->channelConfiguration;
74
    }
75
}
76