1 | <?php |
||
11 | class Twilio |
||
12 | { |
||
13 | /** @var TwilioService */ |
||
14 | protected $twilioService; |
||
15 | |||
16 | /** @var TwilioConfig */ |
||
17 | private $config; |
||
18 | |||
19 | public function __construct(TwilioService $twilioService, TwilioConfig $config) |
||
24 | |||
25 | /** |
||
26 | 13 | * Send a TwilioMessage to the a phone number. |
|
27 | * |
||
28 | 13 | * @param TwilioMessage $message |
|
29 | 13 | * @param string|null $to |
|
30 | 13 | * @param bool $useAlphanumericSender |
|
31 | * |
||
32 | * @return mixed |
||
33 | * @throws TwilioException |
||
34 | * @throws CouldNotSendNotification |
||
35 | */ |
||
36 | public function sendMessage(TwilioMessage $message, ?string $to, bool $useAlphanumericSender = false) |
||
60 | |||
61 | /** |
||
62 | * Send an sms message using the Twilio Service. |
||
63 | * |
||
64 | * @param TwilioSmsMessage $message |
||
65 | 8 | * @param string|null $to |
|
66 | * |
||
67 | * @return MessageInstance |
||
68 | 8 | * @throws CouldNotSendNotification |
|
69 | * @throws TwilioException |
||
70 | */ |
||
71 | 8 | protected function sendSmsMessage(TwilioSmsMessage $message, ?string $to): MessageInstance |
|
107 | |||
108 | /** |
||
109 | * Make a call using the Twilio Service. |
||
110 | 2 | * |
|
111 | * @param TwilioCallMessage $message |
||
112 | * @param string|null $to |
||
113 | 2 | * |
|
114 | * @return CallInstance |
||
115 | * @throws TwilioException |
||
116 | 2 | * @throws CouldNotSendNotification |
|
117 | 2 | */ |
|
118 | protected function makeCall(TwilioCallMessage $message, ?string $to): CallInstance |
||
143 | |||
144 | 10 | /** |
|
145 | * Get the from address from message, or config. |
||
146 | * |
||
147 | * @param TwilioMessage $message |
||
148 | * @return string|null |
||
149 | */ |
||
150 | protected function getFrom(TwilioMessage $message): ?string |
||
154 | |||
155 | 8 | /** |
|
156 | * Get the messaging service SID from message, or config. |
||
157 | * |
||
158 | * @param TwilioSmsMessage $message |
||
159 | * @return string|null |
||
160 | */ |
||
161 | protected function getMessagingServiceSid(TwilioSmsMessage $message): ?string |
||
165 | 2 | ||
166 | 2 | /** |
|
167 | * Get the alphanumeric sender from config, if one exists. |
||
168 | * |
||
169 | * @return string|null |
||
170 | */ |
||
171 | protected function getAlphanumericSender(): ?string |
||
175 | |||
176 | 9 | /** |
|
177 | * @param array $params |
||
178 | 9 | * @param TwilioMessage $message |
|
179 | 9 | * @param array $optionalParams |
|
180 | 3 | * @return Twilio |
|
181 | */ |
||
182 | protected function fillOptionalParams(&$params, $message, $optionalParams): self |
||
192 | } |
||
193 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: