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

BaseMessage::adapterConfigurationArray()   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 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Message;
4
5
/**
6
 * Class BaseMessage
7
 *
8
 * @package IrishDan\NotificationBundle\Message
9
 */
10
abstract class BaseMessage implements MessageInterface
11
{
12
    /**
13
     * @var
14
     */
15
    private $dispatchData;
16
    /**
17
     * @var
18
     */
19
    private $messageData;
20
    /**
21
     * @var
22
     */
23
    private $channel;
24
    /**
25
     * @var array
26
     */
27
    private $adapterConfiguration = [];
28
29
    /**
30
     * @return mixed
31
     */
32
    public function getDispatchData()
33
    {
34
        return $this->dispatchData;
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public function getMessageData()
41
    {
42
        return $this->messageData;
43
    }
44
45
    /**
46
     * @param array $data
47
     */
48
    public function setDispatchData(array $data)
49
    {
50
        $this->dispatchData = $data;
51
    }
52
53
    /**
54
     * @param array $data
55
     */
56
    public function setMessageData(array $data)
57
    {
58
        $this->messageData = $data;
59
    }
60
61
    /**
62
     * @return mixed
63
     */
64
    public function getChannel()
65
    {
66
        return $this->channel;
67
    }
68
69
    /**
70
     * @param $channel
71
     */
72
    public function setChannel($channel)
73
    {
74
        $this->channel = $channel;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getTitle()
81
    {
82
        if (array_key_exists('title', $this->messageData)) {
83
            return $this->messageData['title'];
84
        }
85
86
        return 'NA';
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getRecipient()
93
    {
94
        $recipientKeys = [
95
            'to',
96
            'id',
97
            'channel',
98
            'webhook',
99
        ];
100
101
        foreach ($recipientKeys as $key) {
102
            if (array_key_exists($key, $this->dispatchData)) {
103
                return $this->dispatchData[$key];
104
            }
105
        }
106
107
        return 'NA';
108
    }
109
110
    /**
111
     * @return array
112
     */
113
    public function adapterConfigurationArray()
114
    {
115
        return $this->adapterConfiguration;
116
    }
117
118
    /**
119
     * @param array $data
120
     */
121
    public function setAdapterConfigurationArray(array $data)
122
    {
123
        $this->adapterConfiguration = $data;
124
    }
125
}