1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00
phorge-phorge/externals/twilio-php/Services/Twilio/PartialApplicationHelper.php
Bob Trahan e96c363eef Add SMS support
Summary:
Provides a working SMS implementation with support for Twilio.

This version doesn't really retry if we get any gruff at all. Future versions should retry.

Test Plan: used bin/sms to send messages and look at them.

Reviewers: chad, epriestley

Reviewed By: epriestley

Subscribers: aurelijus, epriestley, Korvin

Maniphest Tasks: T920

Differential Revision: https://secure.phabricator.com/D8930
2014-05-09 12:47:21 -07:00

41 lines
1 KiB
PHP
Executable file

<?php
/**
* Helper class to wrap an object with a modified interface created by
* a partial application of its existing methods.
*
* @category Services
* @package Services_Twilio
* @author Neuman Vong <neuman@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
* @link http://pear.php.net/package/Services_Twilio
*/
class Services_Twilio_PartialApplicationHelper
{
private $callbacks;
public function __construct()
{
$this->callbacks = array();
}
public function set($method, $callback, array $args)
{
if (!is_callable($callback)) {
return FALSE;
}
$this->callbacks[$method] = array($callback, $args);
}
public function __call($method, $args)
{
if (!isset($this->callbacks[$method])) {
throw new Exception("Method not found: $method");
}
list($callback, $cb_args) = $this->callbacks[$method];
return call_user_func_array(
$callback,
array_merge($cb_args, $args)
);
}
}