[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/twilio-php/Services/Twilio/ -> PartialApplicationHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * Helper class to wrap an object with a modified interface created by
   5   * a partial application of its existing methods.
   6   *
   7   * @category Services
   8   * @package  Services_Twilio
   9   * @author   Neuman Vong <[email protected]>
  10   * @license  http://creativecommons.org/licenses/MIT/ MIT
  11   * @link     http://pear.php.net/package/Services_Twilio
  12   */ 
  13  class Services_Twilio_PartialApplicationHelper
  14  {
  15      private $callbacks;
  16  
  17      public function __construct()
  18      {
  19          $this->callbacks = array();
  20      }
  21  
  22      public function set($method, $callback, array $args)
  23      {
  24          if (!is_callable($callback)) {
  25              return FALSE;
  26          }
  27          $this->callbacks[$method] = array($callback, $args);
  28      }
  29  
  30      public function __call($method, $args)
  31      {
  32          if (!isset($this->callbacks[$method])) {
  33              throw new Exception("Method not found: $method");
  34          }
  35          list($callback, $cb_args) = $this->callbacks[$method];
  36          return call_user_func_array(
  37              $callback,
  38              array_merge($cb_args, $args)
  39          );
  40      }
  41  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1