Completed
Push — master ( cd3bab...9e6217 )
by
unknown
03:06
created

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