Completed
Push — master ( cce6f7...7cd9c2 )
by dan
20:28
created

BaseMessage::getRecipient()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 3
nop 0
1
<?php
2
3
namespace IrishDan\NotificationBundle\Message;
4
5
abstract class BaseMessage implements MessageInterface
6
{
7
    private $dispatchData;
8
    private $messageData;
9
    private $channel;
10
11
    public function getDispatchData()
12
    {
13
        return $this->dispatchData;
14
    }
15
16
    public function getMessageData()
17
    {
18
        return $this->messageData;
19
    }
20
21
    public function setDispatchData(array $data)
22
    {
23
        $this->dispatchData = $data;
24
    }
25
26
    public function setMessageData(array $data)
27
    {
28
        $this->messageData = $data;
29
    }
30
31
    public function getChannel()
32
    {
33
        return $this->channel;
34
    }
35
36
    public function setChannel($channel)
37
    {
38
        $this->channel = $channel;
39
    }
40
41
    public function getTitle()
42
    {
43
        if (array_key_exists('title', $this->messageData)) {
44
            return $this->messageData['title'];
45
        }
46
47
        return 'NA';
48
    }
49
50
    public function getRecipient()
51
    {
52
        $recipientKeys = [
53
            'to',
54
            'id',
55
            'channel',
56
            'webhook',
57
        ];
58
59
        foreach ($recipientKeys as $key) {
60
            if (array_key_exists($key, $this->dispatchData)) {
61
                return $this->dispatchData[$key];
62
            }
63
        }
64
65
        return 'NA';
66
    }
67
}