Notification::setMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace WZRD\Push;
4
5
use WZRD\Contracts\Push\Notification as NotificationContract;
6
7
class Notification implements NotificationContract
8
{
9
    /**
10
     * Message.
11
     *
12
     * @var string
13
     */
14
    protected $message;
15
16
    /**
17
     * Data.
18
     *
19
     * @var array
20
     */
21
    protected $data;
22
23
    /**
24
     * Devices.
25
     *
26
     * @var array
27
     */
28
    protected $devices;
29
30
    /**
31
     * Construct.
32
     */
33
    public function __construct()
34
    {
35
        $this->message = '';
36
        $this->data    = $this->devices    = [];
37
    }
38
39
    /**
40
     * Set the notification's message.
41
     *
42
     * @param string $message
43
     *
44
     * @return self
45
     */
46
    public function setMessage($message)
47
    {
48
        $this->message = $message;
49
50
        return $this;
51
    }
52
53
    /**
54
     * Get notification's message.
55
     *
56
     * @return string
57
     */
58
    public function getMessage()
59
    {
60
        return $this->message;
61
    }
62
63
    /**
64
     * Set the notification's data.
65
     *
66
     * @param array $data
67
     *
68
     * @return self
69
     */
70
    public function setData(array $data)
71
    {
72
        $this->data = $data;
73
74
        return $this;
75
    }
76
77
    /**
78
     * Get notification's data.
79
     *
80
     * @return array
81
     */
82
    public function getData()
83
    {
84
        return $this->data;
85
    }
86
87
    /**
88
     * Add a platform to the notification.
89
     *
90
     * @param string $platform
91
     * @param array  $platform
92
     * @param array  $options  Optional
93
     *
94
     * @return self
95
     */
96
    public function addDevices($platform, array $devices, array $options = [])
97
    {
98
        $data = ['devices' => $devices, 'options' => $options];
99
100
        if (!empty($this->devices[$platform])) {
101
            $this->devices[$platform]['devices'] = array_merge($this->devices[$platform]['devices'], $data['devices']);
102
            $this->devices[$platform]['options'] = array_merge($this->devices[$platform]['options'], $data['options']);
103
        } else {
104
            $this->devices[$platform] = $data;
105
        }
106
107
        return $this;
108
    }
109
110
    /**
111
     * Get devices tokens.
112
     *
113
     * @return array
114
     */
115
    public function getDevices()
116
    {
117
        return $this->devices;
118
    }
119
120
    /**
121
     * Get targeted platforms.
122
     *
123
     * @return array
124
     */
125
    public function getTargetedPlatforms()
126
    {
127
        return array_keys($this->devices);
128
    }
129
}
130