Completed
Push — master ( e1ad2f...7f0e8c )
by
unknown
09:06 queued 02:12
created

GammuMessage::channel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace NotificationChannels\Gammu;
4
5
class GammuMessage
6
{
7
    public $destination;
8
9
    public $content;
10
11
    public $sender;
12
13
    public $callback;
14
15
    public $channel;
16
17
    /**
18
     * @param string $content
19
     *
20
     * @return static
21
     */
22 1
    public static function create($content = '')
23
    {
24 1
        return new static($content);
25
    }
26
27
    /**
28
     * Create a new message instance.
29
     *
30
     * @param string $content
31
     */
32 5
    public function __construct($content = '')
33
    {
34 5
        $this->content($content);
35 5
    }
36
37
    /**
38
     * Destination phone number.
39
     *
40
     * @param $phoneNumber
41
     *
42
     * @return $this
43
     */
44 1
    public function to($phoneNumber)
45
    {
46 1
        $this->destination = $phoneNumber;
47
48 1
        return $this;
49
    }
50
51
    /**
52
     * SMS message.
53
     *
54
     * @param $content
55
     *
56
     * @return $this
57
     */
58 5
    public function content($content)
59
    {
60 5
        $this->content = $content;
61
62 5
        return $this;
63
    }
64
65
    /**
66
     * Gammu Api Callback.
67
     *
68
     * @param $content
69
     *
70
     * @return $this
71
     */
72
    public function callback($content)
73
    {
74
        $this->callback = $content;
75
76
        return $this;
77
    }
78
79
    /**
80
     * Gammu Api Redis Channel.
81
     *
82
     * @param $channel
83
     *
84
     * @return $this
85
     */
86
    public function channel($channel)
87
    {
88
        $this->channel = $channel;
89
90
        return $this;
91
    }
92
93
    /**
94
     * Sender Phone ID.
95
     *
96
     * @param $phoneId
97
     *
98
     * @return $this
99
     */
100 1
    public function sender($phoneId = null)
101
    {
102 1
        $this->sender = $phoneId;
103
104 1
        return $this;
105
    }
106
107
    /**
108
     * Determine if Sender Phone ID is not given.
109
     *
110
     * @return bool
111
     */
112
    public function senderNotGiven()
113
    {
114
        return empty($this->sender);
115
    }
116
117
    /**
118
     * Determine if Destination Phone Number is not given.
119
     *
120
     * @return bool
121
     */
122
    public function destinationNotGiven()
123
    {
124
        return empty($this->destination);
125
    }
126
127
    /**
128
     * Determine if Content is not given.
129
     *
130
     * @return bool
131
     */
132
    public function contentNotGiven()
133
    {
134
        return empty($this->content);
135
    }
136
137
    /**
138
     * Returns params payload.
139
     *
140
     * @return array
141
     */
142
    public function toArray()
143
    {
144
        return [
145
            'destination' => $this->destination,
146
            'content' => $this->content,
147
            'sender' => $this->sender,
148
            'callback' => $this->callback,
149
        ];
150
    }
151
}
152