Skip to content

Commit 184a8fc

Browse files
Use func get args and call user func array to pass on all arguments to the twilio calls create and messages sendMessage methods
1 parent 41562fb commit 184a8fc

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/LoggingDecorator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function message($to, $message)
3535
{
3636
$this->logger->info(sprintf('Sending a message ["%s"] to %s', $message, $to));
3737

38-
return $this->wrapped->message($to, $message);
38+
return call_user_func_array([$this->wrapped, 'message'], func_get_args());
3939
}
4040

4141
/**
@@ -48,6 +48,6 @@ public function call($to, $message)
4848
{
4949
$this->logger->info(sprintf('Calling %s', $to));
5050

51-
return $this->wrapped->call($to, $message);
51+
return call_user_func_array([$this->wrapped, 'call'], func_get_args());
5252
}
5353
}

src/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function from($connection)
5454
*/
5555
public function message($to, $message)
5656
{
57-
return $this->defaultConnection()->message($to, $message);
57+
return call_user_func_array([$this->defaultConnection(), 'message'], func_get_args());
5858
}
5959

6060
/**
@@ -65,7 +65,7 @@ public function message($to, $message)
6565
*/
6666
public function call($to, $message)
6767
{
68-
return $this->defaultConnection()->call($to, $message);
68+
return call_user_func_array([$this->defaultConnection(), 'call'], func_get_args());
6969
}
7070

7171
/**

src/Twilio.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ public function __construct($sid, $token, $from, $sslVerify = true)
5454
*/
5555
public function message($to, $message)
5656
{
57-
$twilio = $this->getTwilio();
57+
$arguments = func_get_args();
5858

59-
return $twilio->account->messages->sendMessage($this->from, $to, $message);
59+
array_unshift($arguments, $this->from);
60+
61+
return call_user_func_array([$this->getTwilio()->account->messages, 'sendMessage'], $arguments);
6062
}
6163

6264
/**
@@ -67,17 +69,19 @@ public function message($to, $message)
6769
*/
6870
public function call($to, $message)
6971
{
70-
$twilio = $this->getTwilio();
72+
$arguments = func_get_args();
73+
74+
array_unshift($arguments, $this->from);
7175

7276
if (is_callable($message)) {
7377
$query = http_build_query([
7478
'Twiml' => $this->twiml($message),
7579
]);
7680

77-
$message = 'https://twimlets.com/echo?'.$query;
81+
$arguments[2] = 'https://twimlets.com/echo?'.$query;
7882
}
7983

80-
return $twilio->account->calls->create($this->from, $to, $message);
84+
return call_user_func_array([$this->getTwilio()->account->calls, 'create'], $arguments);
8185
}
8286

8387
/**

0 commit comments

Comments
 (0)