Conditions | 3 |
Paths | 3 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
46 | public function send(string $to, string $message) |
||
47 | { |
||
48 | try { |
||
49 | $result = $this |
||
50 | ->client |
||
51 | ->messages |
||
52 | ->create('+' . $to, ['from' => $this->number, 'body' => $message]); |
||
53 | |||
54 | $sid = $result->sid; |
||
55 | } catch (\Exception $e) { |
||
56 | return [ |
||
57 | 'error' => 'Error sending SMS: ' . $e->getMessage(), |
||
58 | 'sent' => false, |
||
59 | ]; |
||
60 | } |
||
61 | |||
62 | if (empty($sid)) { |
||
63 | return [ |
||
64 | 'error' => 'Error sending SMS: Unknown error', |
||
65 | 'sent' => false, |
||
66 | ]; |
||
67 | } |
||
68 | |||
69 | return [ |
||
70 | 'message_id' => $sid, |
||
71 | 'sent' => true, |
||
72 | ]; |
||
94 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.