Skip to content

Commit 2982dc2

Browse files
committed
Code styles
1 parent 752001b commit 2982dc2

File tree

6 files changed

+81
-31
lines changed

6 files changed

+81
-31
lines changed

src/Twilio.php

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class Twilio
2626
public function __construct(TwilioService $twilioService, TwilioConfig $config)
2727
{
2828
$this->twilioService = $twilioService;
29-
$this->config = $config;
29+
$this->config = $config;
3030
}
3131

3232
/**
3333
* Send a TwilioMessage to the a phone number.
3434
*
3535
* @param TwilioMessage $message
36-
* @param $to
36+
* @param string $to
3737
* @param bool $useAlphanumericSender
3838
* @return mixed
3939
* @throws CouldNotSendNotification
@@ -55,7 +55,14 @@ public function sendMessage(TwilioMessage $message, $to, $useAlphanumericSender
5555
throw CouldNotSendNotification::invalidMessageObject($message);
5656
}
5757

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)
5966
{
6067
$params = [
6168
'from' => $this->getFrom($message),
@@ -69,7 +76,14 @@ protected function sendSmsMessage($message, $to)
6976
return $this->twilioService->messages->create($to, $params);
7077
}
7178

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)
7387
{
7488
return $this->twilioService->calls->create(
7589
$to,
@@ -78,21 +92,31 @@ protected function makeCall($message, $to)
7892
);
7993
}
8094

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)
82103
{
83-
if (! $from = $message->getFrom() ?: $this->config->getFrom()) {
104+
if ( ! $from = $message->getFrom() ?: $this->config->getFrom()) {
84105
throw CouldNotSendNotification::missingFrom();
85106
}
86107

87108
return $from;
88109
}
89110

111+
/**
112+
* Get the alphanumeric sender from config, if one exists.
113+
*
114+
* @return string|null
115+
*/
90116
protected function getAlphanumericSender()
91117
{
92118
if ($sender = $this->config->getAlphanumericSender()) {
93119
return $sender;
94120
}
95-
96-
return null;
97121
}
98122
}

src/TwilioCallMessage.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class TwilioCallMessage extends TwilioMessage
77
/**
88
* Set the message url.
99
*
10-
* @param string $url
11-
*
10+
* @param string $url
1211
* @return $this
1312
*/
1413
public function url($url)

src/TwilioChannel.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class TwilioChannel
2323
/**
2424
* TwilioChannel constructor.
2525
*
26-
* @param Twilio $twilio
27-
* @param Dispatcher $events
26+
* @param Twilio $twilio
27+
* @param Dispatcher $events
2828
*/
2929
public function __construct(Twilio $twilio, Dispatcher $events)
3030
{
@@ -35,23 +35,23 @@ public function __construct(Twilio $twilio, Dispatcher $events)
3535
/**
3636
* Send the given notification.
3737
*
38-
* @param mixed $notifiable
39-
* @param \Illuminate\Notifications\Notification $notification
38+
* @param mixed $notifiable
39+
* @param \Illuminate\Notifications\Notification $notification
4040
* @return mixed
4141
* @throws CouldNotSendNotification
4242
*/
4343
public function send($notifiable, Notification $notification)
4444
{
4545
try {
46-
$to = $this->getTo($notifiable);
47-
$message = $notification->toTwilio($notifiable);
46+
$to = $this->getTo($notifiable);
47+
$message = $notification->toTwilio($notifiable);
4848
$useSender = $this->canReceiveAlphanumericSender($notifiable);
4949

5050
if (is_string($message)) {
5151
$message = new TwilioSmsMessage($message);
5252
}
5353

54-
if (! $message instanceof TwilioMessage) {
54+
if ( ! $message instanceof TwilioMessage) {
5555
throw CouldNotSendNotification::invalidMessageObject($message);
5656
}
5757

@@ -63,6 +63,13 @@ public function send($notifiable, Notification $notification)
6363
}
6464
}
6565

66+
/**
67+
* Get the address to send a notification to.
68+
*
69+
* @param mixed $notifiable
70+
* @return mixed
71+
* @throws CouldNotSendNotification
72+
*/
6673
protected function getTo($notifiable)
6774
{
6875
if ($notifiable->routeNotificationFor('twilio')) {
@@ -76,7 +83,8 @@ protected function getTo($notifiable)
7683
}
7784

7885
/**
79-
* Get the alphanumeric sender
86+
* Get the alphanumeric sender.
87+
*
8088
* @param $notifiable
8189
* @return mixed|null
8290
* @throws CouldNotSendNotification

src/TwilioConfig.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,57 @@ public function __construct(array $config)
1818
$this->config = $config;
1919
}
2020

21+
/**
22+
* Get the account sid.
23+
*
24+
* @return string
25+
*/
2126
public function getAccountSid()
2227
{
2328
return $this->config['account_sid'];
2429
}
2530

31+
/**
32+
* Get the auth token.
33+
*
34+
* @return string
35+
*/
2636
public function getAuthToken()
2737
{
2838
return $this->config['auth_token'];
2939
}
3040

3141
/**
32-
* Get the from entity from config
42+
* Get the default from address.
43+
*
44+
* @return string
3345
*/
3446
public function getFrom()
3547
{
3648
return $this->config['from'];
3749
}
3850

51+
/**
52+
* Get the alphanumeric sender.
53+
*
54+
* @return string
55+
*/
3956
public function getAlphanumericSender()
4057
{
4158
if (isset($this->config['alphanumeric_sender'])) {
4259
return $this->config['alphanumeric_sender'];
4360
}
44-
45-
return null;
4661
}
4762

63+
/**
64+
* Get the service sid.
65+
*
66+
* @return string
67+
*/
4868
public function getServiceSid()
4969
{
5070
if (isset($this->config['sms_service_sid'])) {
5171
return $this->config['sms_service_sid'];
5272
}
53-
54-
return null;
5573
}
5674
}

src/TwilioMessage.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ abstract class TwilioMessage
1919
public $from;
2020

2121
/**
22+
* Create a message object.
2223
* @param string $content
23-
*
2424
* @return static
2525
*/
2626
public static function create($content = '')
@@ -31,7 +31,7 @@ public static function create($content = '')
3131
/**
3232
* Create a new message instance.
3333
*
34-
* @param string $content
34+
* @param string $content
3535
*/
3636
public function __construct($content = '')
3737
{
@@ -41,8 +41,7 @@ public function __construct($content = '')
4141
/**
4242
* Set the message content.
4343
*
44-
* @param string $content
45-
*
44+
* @param string $content
4645
* @return $this
4746
*/
4847
public function content($content)
@@ -55,8 +54,7 @@ public function content($content)
5554
/**
5655
* Set the phone number the message should be sent from.
5756
*
58-
* @param string $from
59-
*
57+
* @param string $from
6058
* @return $this
6159
*/
6260
public function from($from)
@@ -68,6 +66,7 @@ public function from($from)
6866

6967
/**
7068
* Get the from address
69+
*
7170
* @return string
7271
*/
7372
public function getFrom()

src/TwilioSmsMessage.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class TwilioSmsMessage extends TwilioMessage
1010
public $alphaNumSender = null;
1111

1212
/**
13-
* Get the from address of this message
13+
* Get the from address of this message.
14+
*
1415
* @return null|string
1516
*/
1617
public function getFrom()
@@ -27,7 +28,8 @@ public function getFrom()
2728
}
2829

2930
/**
30-
* Set the alphanumeric sender
31+
* Set the alphanumeric sender.
32+
*
3133
* @param $sender
3234
*/
3335
public function sender($sender)

0 commit comments

Comments
 (0)