PartialApplicationHelper.php
Current file: /Users/kevin/code/twilio-php/Services/Twilio/PartialApplicationHelper.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
33.33% 1 / 3 CRAP
84.62% 11 / 13
Services_Twilio_PartialApplicationHelper
0.00% 0 / 1
33.33% 1 / 3 5.09
84.62% 11 / 13
 __construct()
100.00% 1 / 1 1
100.00% 2 / 2
 set($method, $callback, array $args)
0.00% 0 / 1 2.06
75.00% 3 / 4
 __call($method, $args)
0.00% 0 / 1 2.01
85.71% 6 / 7


       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 <neuman@twilio.com>                          
      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               1 :         $this->callbacks = array();                                   
      20               1 :     }                                                                 
      21                 :                                                                       
      22                 :     public function set($method, $callback, array $args)              
      23                 :     {                                                                 
      24               1 :         if (!is_callable($callback)) {                                
      25               0 :             return FALSE;                                             
      26                 :         }                                                             
      27               1 :         $this->callbacks[$method] = array($callback, $args);          
      28               1 :     }                                                                 
      29                 :                                                                       
      30                 :     public function __call($method, $args)                            
      31                 :     {                                                                 
      32               1 :         if (!isset($this->callbacks[$method])) {                      
      33               0 :             throw new Exception("Method not found: $method");         
      34                 :         }                                                             
      35               1 :         list($callback, $cb_args) = $this->callbacks[$method];        
      36               1 :         return call_user_func_array(                                  
      37               1 :             $callback,                                                
      38               1 :             array_merge($cb_args, $args)                              
      39               1 :         );                                                            
      40                 :     }                                                                 
      41                 : }                                                                     

Generated by PHP_CodeCoverage 1.1.2 using PHP 5.3.13 and PHPUnit 3.6.11 at Mon Jun 4 22:46:14 PDT 2012.