ExponentMessage::setSound()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace NotificationChannels\Exponent;
4
5
/**
6
 * Class ExponentMessage.
7
 */
8
class ExponentMessage
9
{
10
    protected $tokens = [];
11
12
    protected $title;
13
    protected $body;
14
15
    protected $sound = 'default';
16
17
    protected $badge = 0;
18
19
    protected $ttl = 0;
20
21
    protected $channelId = 'Default';
22
23
    protected $jsonData = [];
24
25
    public static function create()
26
    {
27
        return new static();
28
    }
29
30
    /**
31
     * @param array $tokens
32
     * @return ExponentMessage
33
     */
34
    public function setTokens($tokens)
35
    {
36
        $this->tokens = $tokens;
37
38
        return $this;
39
    }
40
41
    /**
42
     * @param mixed $title
43
     * @return ExponentMessage
44
     */
45
    public function setTitle($title)
46
    {
47
        $this->title = $title;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param mixed $body
54
     * @return ExponentMessage
55
     */
56
    public function setBody($body)
57
    {
58
        $this->body = $body;
59
60
        return $this;
61
    }
62
63
    /**
64
     * @param string $sound
65
     * @return ExponentMessage
66
     */
67
    public function setSound($sound)
68
    {
69
        $this->sound = $sound;
70
71
        return $this;
72
    }
73
74
    /**
75
     * @param int $badge
76
     * @return ExponentMessage
77
     */
78
    public function setBadge($badge)
79
    {
80
        $this->badge = $badge;
81
82
        return $this;
83
    }
84
85
    /**
86
     * @param int $ttl
87
     * @return ExponentMessage
88
     */
89
    public function setTtl($ttl)
90
    {
91
        $this->ttl = $ttl;
92
93
        return $this;
94
    }
95
96
    /**
97
     * @param string $channelId
98
     * @return ExponentMessage
99
     */
100
    public function setChannelId($channelId)
101
    {
102
        $this->channelId = $channelId;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @param array $jsonData
109
     * @return ExponentMessage
110
     */
111
    public function setJsonData($jsonData)
112
    {
113
        $this->jsonData = $jsonData;
114
115
        return $this;
116
    }
117
118
    /**
119
     * @return array
120
     */
121
    public function getTokens()
122
    {
123
        return $this->tokens;
124
    }
125
126
    /**
127
     * Get the instance as an array.
128
     *
129
     * @return array
130
     */
131
    public function toArray()
132
    {
133
        return [
134
            'title' => $this->title,
135
            'body' => $this->body,
136
            'sound' => $this->sound,
137
            'badge' => $this->badge,
138
            'ttl' => $this->ttl,
139
            'channelId' => $this->channelId,
140
            'data' => empty($this->jsonData) ? '{}' : json_encode($this->jsonData),
141
        ];
142
    }
143
}
144