BaseMessage   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 0
dl 0
loc 96
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDispatchData() 0 4 1
A getMessageData() 0 4 1
A setDispatchData() 0 4 1
A setMessageData() 0 4 1
A getChannel() 0 4 1
A setChannel() 0 4 1
A getTitle() 0 8 2
A getRecipient() 0 17 3
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
    /**
26
     * @return mixed
27
     */
28
    public function getDispatchData()
29
    {
30
        return $this->dispatchData;
31
    }
32
33
    /**
34
     * @return mixed
35
     */
36
    public function getMessageData()
37
    {
38
        return $this->messageData;
39
    }
40
41
    /**
42
     * @param array $data
43
     */
44
    public function setDispatchData(array $data)
45
    {
46
        $this->dispatchData = $data;
47
    }
48
49
    /**
50
     * @param array $data
51
     */
52
    public function setMessageData(array $data)
53
    {
54
        $this->messageData = $data;
55
    }
56
57
    /**
58
     * @return mixed
59
     */
60
    public function getChannel()
61
    {
62
        return $this->channel;
63
    }
64
65
    /**
66
     * @param $channel
67
     */
68
    public function setChannel($channel)
69
    {
70
        $this->channel = $channel;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getTitle()
77
    {
78
        if (array_key_exists('title', $this->messageData)) {
79
            return $this->messageData['title'];
80
        }
81
82
        return 'NA';
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getRecipient()
89
    {
90
        $recipientKeys = [
91
            'to',
92
            'id',
93
            'channel',
94
            'webhook',
95
        ];
96
97
        foreach ($recipientKeys as $key) {
98
            if (array_key_exists($key, $this->dispatchData)) {
99
                return $this->dispatchData[$key];
100
            }
101
        }
102
103
        return 'NA';
104
    }
105
}