TextlocalMessage   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 142
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 142
rs 10
c 0
b 0
f 0
wmc 9

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A at() 0 5 1
A promotional() 0 5 1
A test() 0 5 1
A cc() 0 6 2
A from() 0 5 1
A transactional() 0 5 1
A content() 0 5 1
1
<?php
2
3
namespace NotificationChannels\Textlocal;
4
5
class TextlocalMessage
6
{
7
    /**
8
     * The phone numbers copy of the message should be sent to.
9
     *
10
     * @var string
11
     */
12
    public $cc = [];
13
14
    /**
15
     * The sender the message should be sent from.
16
     *
17
     * @var string
18
     */
19
    public $from;
20
21
    /**
22
     * The time at which the message should be sent.
23
     *
24
     * @var string|number
25
     */
26
    public $at;
27
28
    /**
29
     * The message content.
30
     *
31
     * @var string
32
     */
33
    public $content;
34
35
    /**
36
     * The Textlocal account through which the message should be sent.
37
     *
38
     * @var string
39
     */
40
    public $account = 'promotional';
41
42
    /**
43
     * Indication whether it's a test or not.
44
     *
45
     * @var string
46
     */
47
    public $test = false;
48
49
    /**
50
     * Create a new message instance.
51
     *
52
     * @param string $content
53
     * @return void
54
     */
55
    public function __construct($content = '')
56
    {
57
        $this->content = $content;
58
    }
59
60
    /**
61
     * Set the message content.
62
     *
63
     * @param string $content
64
     * @return $this
65
     */
66
    public function content($content)
67
    {
68
        $this->content = trim($content);
69
70
        return $this;
71
    }
72
73
    /**
74
     * Set the numbers copy of the message should be sent to.
75
     *
76
     * @param string|array $cc
77
     * @return $this
78
     */
79
    public function cc($cc)
80
    {
81
        $cc = is_string($cc) ? [$cc] : $cc;
82
        $this->cc = $cc;
0 ignored issues
show
Documentation Bug introduced by
It seems like $cc of type array or array<integer,string> is incompatible with the declared type string of property $cc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
83
84
        return $this;
85
    }
86
87
    /**
88
     * Set the sender the message should be sent from.
89
     *
90
     * @param string $from
91
     * @return $this
92
     */
93
    public function from($from)
94
    {
95
        $this->from = $from;
96
97
        return $this;
98
    }
99
100
    /**
101
     * Set the date and time at which the message should be sent.
102
     *
103
     * @param number $at
104
     * @return $this
105
     */
106
    public function at($at)
107
    {
108
        $this->at = $at;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Set the flag for test as true, for the message.
115
     *
116
     * @return $this
117
     */
118
    public function test()
119
    {
120
        $this->test = true;
0 ignored issues
show
Documentation Bug introduced by
The property $test was declared of type string, but true is of type true. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
121
122
        return $this;
123
    }
124
125
    /**
126
     * Set Textlocal account from which the message should be sent as transactional.
127
     *
128
     * @return $this
129
     */
130
    public function transactional()
131
    {
132
        $this->account = 'transactional';
133
134
        return $this;
135
    }
136
137
    /**
138
     * Set Textlocal account from which the message should be sent as promotional.
139
     *
140
     * @return $this
141
     */
142
    public function promotional()
143
    {
144
        $this->account = 'promotional';
145
146
        return $this;
147
    }
148
}
149