Completed
Pull Request — master (#35)
by
unknown
12:18
created

GcmMessage::icon()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace NotificationChannels\Gcm;
4
5
class GcmMessage
6
{
7
    /**
8
     * Normal priority option.
9
     *
10
     * @var string
11
     */
12
    const PRIORITY_NORMAL = 'normal';
13
14
    /**
15
     * High priority option.
16
     *
17
     * @var string
18
     */
19
    const PRIORITY_HIGH = 'high';
20
21
    /**
22
     * Default sound option.
23
     *
24
     * @var string
25
     */
26
    const DEFAULT_SOUND = 'default';
27
28
    /**
29
     * The title of the notification.
30
     *
31
     * @var string
32
     */
33
    public $title;
34
35
    /**
36
     * The icon of the notification.
37
     *
38
     * @var string
39
     */
40
    public $icon;
41
42
    /**
43
     * The message of the notification.
44
     *
45
     * @var string
46
     */
47
    public $message;
48
49
    /**
50
     * The priority of the notification.
51
     *
52
     * @var string
53
     */
54
    public $priority = self::PRIORITY_NORMAL;
55
56
    /**
57
     * Notification sound.
58
     *
59
     * @var string
60
     */
61
    public $sound = self::DEFAULT_SOUND;
62
63
    /**
64
     * Additional data of the notification.
65
     *
66
     * @var array
67
     */
68
    public $data = [];
69
70
    /**
71
     * Additional notification data of the notification.
72
     *
73
     * @var array
74
     */
75
    public $notification = [];
76
77
    /**
78
     * Create a new message instance.
79
     *
80
     * @param string|null $title
81
     * @param string|null $message
82
     * @param array $data
83
     * @param string $priority
84
     * @return static
85
     */
86 1
    public static function create($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND, $notification = [])
87
    {
88 1
        return new static($title, $message, $data, $priority, $sound, $notification);
89
    }
90
91
    /**
92
     * Create a new message instance.
93
     *
94
     * @param string|null $title
95
     * @param string|null $message
96
     * @param array $data
97
     * @param string $priority
98
     * @param string $sound
99
     */
100 11
    public function __construct($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND, $notification = [])
101
    {
102 11
        $this->title = $title;
103 11
        $this->message = $message;
104 11
        $this->data = $data;
105 11
        $this->priority = $priority;
106 11
        $this->sound = $sound;
107 11
        $this->notification = $notification;
108 11
    }
109
110
    /**
111
     * Set the title of the notification.
112
     *
113
     * @param string $title
114
     * @return $this
115
     */
116 1
    public function title($title)
117
    {
118 1
        $this->title = $title;
119
120 1
        return $this;
121
    }
122
123
    /**
124
     * Set the title of the notification.
125
     *
126
     * @param string $title
0 ignored issues
show
Bug introduced by
There is no parameter named $title. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
127
     * @return $this
128
     */
129
    public function icon($icon)
130
    {
131
        $this->icon = $icon;
132
133
        return $this;
134
    }
135
136
    /**
137
     * Set the message of the notification.
138
     *
139
     * @param string $message
140
     * @return $this
141
     */
142 1
    public function message($message)
143
    {
144 1
        $this->message = $message;
145
146 1
        return $this;
147
    }
148
149
    /**
150
     * Set the priority of the notification.
151
     *
152
     * @param string $priority
153
     * @return $this
154
     */
155 1
    public function priority($priority)
156
    {
157 1
        $this->priority = $priority;
158
159 1
        return $this;
160
    }
161
162
    /**
163
     * Set the sound for notification.
164
     *
165
     * @param string $sound
166
     * @return $this
167
     */
168 1
    public function sound($sound)
169
    {
170 1
        $this->sound = $sound;
171
172 1
        return $this;
173
    }
174
175
    /**
176
     * Add data to the notification.
177
     *
178
     * @param string $key
179
     * @param mixed $value
180
     * @return $this
181
     */
182 1
    public function data($key, $value)
183
    {
184 1
        $this->data[$key] = $value;
185
186 1
        return $this;
187
    }
188
189
    /**
190
     * Override the data of the notification.
191
     *
192
     * @param array $data
193
     * @return $this
194
     */
195
    public function setData($data)
196
    {
197
        $this->data = $data;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Add notification data to the notification.
204
     *
205
     * @param string $key
206
     * @param mixed $value
207
     * @return $this
208
     */
209 1
    public function notification($key, $value)
210
    {
211 1
        $this->notification[$key] = $value;
212
213 1
        return $this;
214
    }
215
216
    /**
217
     * Override the notification data of the notification.
218
     *
219
     * @param array $notification
220
     * @return $this
221
     */
222
    public function setNotification($notification)
223
    {
224
        $this->notification = $notification;
225
226
        return $this;
227
    }
228
229
    /**
230
     * Add an action to the notification.
231
     *
232
     * @param string $action
233
     * @param mixed $params
234
     * @return $this
235
     */
236
    public function action($action, $params = null)
237
    {
238
        return $this->data('action', [
239
            'action' => $action,
240
            'params' => $params,
241
        ]);
242
    }
243
}
244