@@ -26,14 +26,14 @@ class Twilio
26
26
public function __construct (TwilioService $ twilioService , TwilioConfig $ config )
27
27
{
28
28
$ this ->twilioService = $ twilioService ;
29
- $ this ->config = $ config ;
29
+ $ this ->config = $ config ;
30
30
}
31
31
32
32
/**
33
33
* Send a TwilioMessage to the a phone number.
34
34
*
35
35
* @param TwilioMessage $message
36
- * @param $to
36
+ * @param string $to
37
37
* @param bool $useAlphanumericSender
38
38
* @return mixed
39
39
* @throws CouldNotSendNotification
@@ -55,7 +55,14 @@ public function sendMessage(TwilioMessage $message, $to, $useAlphanumericSender
55
55
throw CouldNotSendNotification::invalidMessageObject ($ message );
56
56
}
57
57
58
- protected function sendSmsMessage ($ message , $ to )
58
+ /**
59
+ * Send an sms message using the Twilio Service.
60
+ *
61
+ * @param TwilioSmsMessage $message
62
+ * @param string $to
63
+ * @return \Twilio\Rest\Api\V2010\Account\MessageInstance
64
+ */
65
+ protected function sendSmsMessage (TwilioSmsMessage $ message , $ to )
59
66
{
60
67
$ params = [
61
68
'from ' => $ this ->getFrom ($ message ),
@@ -69,7 +76,14 @@ protected function sendSmsMessage($message, $to)
69
76
return $ this ->twilioService ->messages ->create ($ to , $ params );
70
77
}
71
78
72
- protected function makeCall ($ message , $ to )
79
+ /**
80
+ * Make a call using the Twilio Service.
81
+ *
82
+ * @param TwilioCallMessage $message
83
+ * @param string $to
84
+ * @return \Twilio\Rest\Api\V2010\Account\CallInstance
85
+ */
86
+ protected function makeCall (TwilioCallMessage $ message , $ to )
73
87
{
74
88
return $ this ->twilioService ->calls ->create (
75
89
$ to ,
@@ -78,21 +92,31 @@ protected function makeCall($message, $to)
78
92
);
79
93
}
80
94
81
- protected function getFrom ($ message )
95
+ /**
96
+ * Get the from address from message, or config.
97
+ *
98
+ * @param TwilioMessage $message
99
+ * @return string
100
+ * @throws CouldNotSendNotification
101
+ */
102
+ protected function getFrom (TwilioMessage $ message )
82
103
{
83
- if (! $ from = $ message ->getFrom () ?: $ this ->config ->getFrom ()) {
104
+ if ( ! $ from = $ message ->getFrom () ?: $ this ->config ->getFrom ()) {
84
105
throw CouldNotSendNotification::missingFrom ();
85
106
}
86
107
87
108
return $ from ;
88
109
}
89
110
111
+ /**
112
+ * Get the alphanumeric sender from config, if one exists.
113
+ *
114
+ * @return string|null
115
+ */
90
116
protected function getAlphanumericSender ()
91
117
{
92
118
if ($ sender = $ this ->config ->getAlphanumericSender ()) {
93
119
return $ sender ;
94
120
}
95
-
96
- return null ;
97
121
}
98
122
}
0 commit comments